home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 38 / Amiga Format CD38 (1999-03-15)(Future Publishing)(GB)(Track 1 of 3)[!][issue 1999-04].iso / -screenplay- / shareware / wreckage / wreckage.bb2.ascii < prev    next >
Text File  |  1999-02-08  |  105KB  |  5,178 lines

  1. ;wreckage Revision XV45
  2. ;Copyright(C) 1997,1998,1999 Christos Dimitrakakis
  3.  
  4. version$="XV45"
  5. copyright$=Chr$(169)+"1998,"
  6.  
  7. #SUSP_HEIGHT=12
  8.  
  9. .funcs
  10.  
  11.  
  12. ;   CONTROLLER
  13. ;=================
  14.  
  15. NEWTYPE .ctrl
  16.  
  17.   dx.f
  18.   dx1
  19.   d2x
  20.   d2x1
  21.   d2x2
  22.   d3x
  23.   nd3x
  24.   force
  25.   force1
  26.   a
  27. End NEWTYPE
  28.  
  29. DEFTYPE .ctrl ctrl
  30.  
  31.  
  32.  
  33. ;   RIGID OBJECT
  34. ;=================
  35.  
  36. NEWTYPE .robj
  37.   m.f         ;mass
  38.   x:y:z       ;position
  39.   ux:uy:uz    ;velocity
  40.   Ix:Iy:Iz    ;angular moments
  41.   ax:ay:az    ;angle
  42.   wx:wy:wz    ;angular velocity
  43. End NEWTYPE
  44.  
  45.  
  46.  
  47. ;  SURFACE SPRING
  48. ;==================
  49.  
  50. NEWTYPE .ispring
  51.   *obj.robj   ;which object it is attached to
  52.   x1.f:y1:z1  ;attachment point
  53.   x2:y2:z2    ;normal length (!)
  54.   k           ;rigidity
  55.   d           ;damping factor
  56. End NEWTYPE
  57.  
  58.  
  59. ;  CONNECTING SPRING
  60. ;=====================
  61.  
  62. NEWTYPE .spring
  63. ;  *obj1.robj  ;object attached to
  64. ;  *obj2.robj  ;other object
  65. ;  x1.f:y1:z1  ;attachment point 1
  66. ;  x2:y2:z2    ;attachment point 2
  67.   x0.f
  68.   k           ;rigidity
  69.   d           ;damping factor
  70. End NEWTYPE
  71.  
  72.  
  73. dt.f=1/25
  74.  
  75. Dim susplist.spring(10)
  76.  
  77. DEFTYPE .robj player
  78. DEFTYPE .ispring flsusp,frsusp,rlsusp,rrsusp
  79.  
  80. USEPATH player
  81. \m=1000
  82. \Ix=500
  83. \Iy=500
  84. \Iz=500
  85. \ux=0
  86. \uy=0
  87. \uz=0
  88. \ax=0
  89. \ay=0
  90. \az=0
  91. \wx=0
  92. \wy=0
  93. \wz=0
  94. USEPATH flsusp
  95. *obj=player
  96. \x1=-5
  97.  
  98.  
  99.  
  100.  
  101. Function.f land1{vx,vy}
  102.   SHARED f1.f,f2.f,f3.f,f4.f,f5.f,f6.f,f7.f,f8.f,f9.f,f10.f,tr_vx,tr_vy
  103.   SHARED map_slip,flat_road
  104.   SHARED mountycnt1.f,mountxcnt1.f
  105.   SHARED mountycnt2.f,mountxcnt2.f
  106.   SHARED mountycnt3.f,mountxcnt3.f
  107.   SHARED fmountcnt.f
  108.  
  109.  
  110.   vx/100
  111.   vy/100
  112.   vy+160
  113.   vx+60
  114.  
  115.  
  116.   mfx.f=(vx) MOD 80
  117.   mfx+Frac(vx)
  118.   If mfx>40
  119.     mfx = 80-mfx
  120.   EndIf
  121.   mfx=20*(1+Sin((Pi*HTan(mfx/50)-.5*Pi)))
  122.      ;20*(1+Sin((Pi*HTan(mfx/50)-.5*Pi)))
  123.   vx=vx+mfx
  124.  
  125.  
  126.   mfy.f=(vy) MOD 80
  127.   mfy+Frac(vy)
  128.   If mfy>40
  129.     mfy = 80-mfy
  130.   EndIf
  131.   mfy=20*(1+Sin((Pi*HTan(mfy/50)-.5*Pi)))
  132.   vy=vy+mfy
  133.  
  134.   vtotal.f=vx+vy
  135.  
  136. ;  If Abs(vx)<20
  137. ;    vx=0
  138. ;  Else
  139. ;    vx=vx-20*Sgn(vx)
  140. ;  EndIf
  141. ;
  142. ;  If Abs(vy)<20
  143. ;    vy=-100
  144. ;  Else
  145. ;    vy=vy-20*Sgn(vy)-100
  146. ;  EndIf
  147.  
  148.   vy1.f=vy*f1
  149.   vx2.f=vx*f2
  150.  
  151.  
  152. ;  vy3.f=.1*(vy-mountycnt1)
  153. ;  vx4.f=.1*(vx-mountxcnt1)
  154. ;  vv1.f=vy3^2+vx4^2
  155. ;  rtf.f=10-10*(Exp(-fmountcnt*(vv1)))
  156.  
  157. ;  vy3.f=.1*(vy-mountycnt2)
  158. ;  vx4.f=.1*(vx-mountxcnt2)
  159. ;  vv1.f=vy3^2+vx4^2
  160. ;  rtf.f-200*(Exp(-.2*(vv1)))
  161. ;
  162. ;  vy3.f=.1*(vy-mountycnt3)
  163. ;  vx4.f=.1*(vx-mountxcnt3)
  164. ;  vv1.f=vy3^2+vx4^2
  165. ;  rtf.f+100*(Exp(-.1*(vv1)))
  166.  
  167.  
  168.   CNIF1=1
  169.  
  170.   ;ret.f=(vx^2+vy^2)*.05
  171.   rt.f=Cos(f9*vx);-Cos(f6*vx)
  172.   rt+Cos(f10*vy);-Cos(f8*vy)
  173.   ret.f=0
  174.   If map_slip=-1
  175.     ret.f+(.5*Cos(vy1)+Cos(vy1*f3)+Cos(vy1*f5)+Cos(vy1*f7))
  176.     ret.f+(.5*Cos(vx2)+Cos(vx2*f4)+Cos(vx2*f6)+Cos(vx2*f8))
  177.   Else
  178.     If flat_road=True
  179.       ret.f+.25*Cos(vy1*.5)+.5*Cos(vy1*.25)+Cos(vy1*.125)+2*Cos(vy1*.0625)
  180.       ret.f+.25*Cos(vx2*.5)+.5*Cos(vx2*.25)+Cos(vx2*.125)+2*Cos(vx2*.0625)
  181.         ret.f+2
  182. ;        ret.f+.15*(.5*Cos(vy1)+Cos(vy1*f3)+Cos(vy1*f5)+Cos(vy1*f7))
  183. ;        ret.f+.15*(.5*Cos(vx2)+Cos(vx2*f4)+Cos(vx2*f6)+Cos(vx2*f8))
  184.     Else
  185.         ret.f+(.5*Cos(vy1)+Cos(vy1*f3)+Cos(vy1*f5)+Cos(vy1*f7))
  186.         ret.f+(.5*Cos(vx2)+Cos(vx2*f4)+Cos(vx2*f6)+Cos(vx2*f8))
  187. ;      ret.f+(.5*Cos(vy1)+Cos(vy1*.5)+2*Cos(vy1*.25)+4*Cos(vy1*.125))
  188. ;      ret.f+(.5*Cos(vx2)+Cos(vx2*.5)+2*Cos(vx2*.25)+4*Cos(vx2*.125))
  189.     EndIf
  190.   EndIf
  191.  
  192. ;  ret.f=QLimit(ret,-4,4)
  193.   ret.f=QLimit(80*(rt*ret),-4000,4000)
  194.   CEND
  195.  
  196.   ;ret.f=10000*rtf
  197.   Function Return ret;10*vtotal
  198. End Function
  199.  
  200.  
  201. Function.f land2{vx,vy}
  202.   SHARED f1.f,f2.f,f3.f,f4.f,f5.f,f6.f,f7.f,f8.f
  203.   vx/100
  204.   vy/100
  205.   ret.f=4*(f1*vx)^3+3*(f2*vx)^2+2*f3*vx+f4
  206. ;  ret+4*(f5*vy)^3+3*(f6*vy)^2+2*f7*vy+f8
  207.   ret-20*Sin(vy*.1)
  208.   ret.f=QLimit(ret,-4000,4000)
  209.   Function Return ret
  210. End Function
  211.  
  212.  
  213. Function.f land2x{vx}
  214.   SHARED f1.f,f2.f,f3.f,f4.f,f5.f,f6.f,f7.f,f8.f
  215.   vx/100
  216.   vy/100
  217.   ret.f=4*(f1*vx)^3+3*(f2*vx)^2+2*f3*vx+f4
  218.   ret.f=QLimit(ret,-4000,4000)
  219.   Function Return ret
  220. End Function
  221.  
  222. Function.f land2y{vy}
  223.   SHARED f1.f,f2.f,f3.f,f4.f,f5.f,f6.f,f7.f,f8.f
  224.   vx/100
  225.   vy/100
  226. ;  ret.f=4*(f5*vy)^3+3*(f6*vy)^2+2*f7*vy+f8
  227.   ret.f=-20*Sin(vy*.1)
  228.   ret.f=QLimit(ret,-4000,4000)
  229.   Function Return ret
  230. End Function
  231.  
  232. ;BANKS
  233. ;-----
  234.  
  235.  
  236.  
  237. #SOUNDCACHE=0
  238. #TURBOCACHE=1
  239.  
  240. ;INI
  241. ;---
  242.  
  243. file_missing.b=False
  244. Statement safe_loadsound{x,x$}
  245.   SHARED file_missing
  246.  
  247.   If Exists(x$)
  248.     If OpenFile(0,x$)
  249.       If AvailMem_(#MEMF_LARGEST|#MEMF_CHIP)>Lof(0)
  250.         LoadSound x,x$
  251.       Else
  252.         file_missing=True
  253.         tempb.b=RTEZRequest("Memory low","Can't load "+x$,"OK")
  254.       EndIf
  255.       CloseFile 0
  256.     Else
  257.       tempb.b=RTEZRequest("File Error","Can't open "+x$,"OK")
  258.       file_missing=True
  259.     EndIf
  260.   Else
  261.     file_missing=True
  262.     tempb.b=RTEZRequest("File Error","Can't find "+x$,"OK")
  263.   EndIf
  264.  
  265. End Statement
  266.  
  267.  
  268. Statement safe_loadshape{x,x$}
  269.   SHARED file_missing
  270.   If Exists(x$)
  271.     LoadShape x,x$
  272.   Else
  273.     file_missing=True
  274.     tempb.b=RTEZRequest("File Error","Can't find "+x$,"OK")
  275.   EndIf
  276. End Statement
  277.  
  278.  
  279. ;FLAGS
  280. ;=====
  281.  
  282. #SYSTEM_FRIENDLY=0
  283. #DBUG=0
  284.  
  285.  
  286. NoCli
  287. WBStartup
  288.  
  289. points.l=0
  290. points1.l=0
  291. points2.l=0
  292. points3.l=0
  293.  
  294. p2=2*Pi
  295.  
  296.  
  297.  
  298.  
  299.  
  300. NEWTYPE .MyScreenMode
  301.   DisplayID.l
  302.   DisplayWidth.w
  303.   DisplayHeight.w
  304.   DisplayDepth.w
  305.   OverscanType.w
  306.   Autoscroll.l
  307. End NEWTYPE
  308.  
  309. CNIF #SYSTEM_FRIENDLY=1
  310.   *newscr.MyScreenMode=RTEZScreenModeRequest("Select Mode")
  311.   If *newscr>0
  312.     scrx=*newscr\DisplayWidth
  313.     scry=*newscr\DisplayHeight
  314.     scrt=*newscr\DisplayDepth
  315.     scrid.l=*newscr\DisplayID
  316.     If ScreenTags(1,"Wreckage Exp."+version$,#SA_Width,scrx,#SA_Height,scry,#SA_DisplayID,scrid,#SA_Depth,scrt)
  317.       Delay_(200)
  318.     Else
  319.       Goto finish
  320.     EndIf
  321.   EndIf
  322. CEND
  323.  
  324.  
  325.  
  326.  
  327.  
  328. ;enginefile$="SAMPLES:SFX/ORIGINAL_ENGINE.raw"
  329. ;enginefile$="SAMPLES:SFX/SW_RenaultV10'94.raw"
  330. ;enginefile$="SFX/engine4t"
  331. ;enginefile$="engine"
  332. enginefile$="SFX/engine2"
  333.  
  334.  
  335. safe_loadshape {0,"GFX/RevMeter4c.iff"}
  336. safe_loadshape {1,"GFX/Hood4c.iff"}
  337. safe_loadshape {2,"GFX/Hood32c.iff"}
  338.  
  339. safe_loadsound {0,"SFX/tyres"}
  340. safe_loadsound {1,enginefile$}
  341. safe_loadsound {2,"SFX/out_of_road"}
  342. safe_loadsound {3,"SFX/skidmetal"}
  343. safe_loadsound {4,enginefile$}
  344. safe_loadsound {5,"SFX/boom"}
  345. safe_loadsound {6,"SFX/crash1"}
  346. safe_loadsound {7,"SFX/engine2t"}
  347. safe_loadsound {8,"SFX/tyres_short"}
  348. safe_loadsound {9,"SFX/out_of_road3"}
  349.  
  350. If file_missing=True Then Goto finish3
  351.  
  352.  
  353.  
  354.  
  355. DEFTYPE .sound *mysound
  356.  
  357. *mysound=Addr Sound(7)
  358. InitBank #TURBOCACHE,*mysound\_length*2,65536
  359.  
  360. *mysound=Addr Sound(4)
  361.  
  362. InitBank #SOUNDCACHE,*mysound\_length*2,65536
  363.  
  364.  
  365. ;LoadSound 1,"SAMPLES:SFX/ORIGINAL_ENGINE.raw"
  366. ;LoadSound 1, "SAMPLES:SFX/SW_RenaultV10'94.raw"
  367. ;LoadSound 1,"SAMPLES:SFX/CM_ENGINE.raw"
  368.  
  369. Select_CTRL:
  370. x$=Centre$("Wreckage",40)+Chr$(10)
  371. x$+Centre$("Experimental Version "+version$,40)+Chr$(10)
  372. x$+Centre$("Copyright "+copyright$+" Christos Dimitrakakis",40)
  373.  
  374. dummy=RTEZRequest("Wreckage "+version$+"(FreeWare)",x$,"OK")
  375. nofframes.l=0
  376. nofcounts.l=0
  377. prefs_error=True
  378. ;If control_method=1
  379.   If Exists("ENV:AnalogJoy.prefs")
  380.     If ReadFile(0,"ENV:AnalogJoy.prefs")
  381.       FileInput 0
  382.       x$=Edit$(30)
  383.       If x$="ANALOGJOYPREFS"
  384.         prevsversion=Edit(5)
  385.         x$=Edit$(30)
  386.         If x$="TYPE"
  387.           x$=Edit$(30)
  388.           If x$="STANDARD_PORT1"
  389.             ajoy_rd=0
  390.             x$=Edit$(30)
  391.             If x$="CX"Then cx=Edit(30):ajoy_rd+1
  392.             x$=Edit$(30)
  393.             If x$="CY"Then cy=Edit(30):ajoy_rd+1
  394.             x$=Edit$(30)
  395.             If x$="MX"Then mx=Edit(30):ajoy_rd+1
  396.             x$=Edit$(30)
  397.             If x$="MY"Then my=Edit(30):ajoy_rd+1
  398.             x$=Edit$(30)
  399.             If x$="NX"Then nx=Edit(30):ajoy_rd+1
  400.             x$=Edit$(30)
  401.             If x$="NY"Then ny=Edit(30):ajoy_rd+1
  402.             If ajoy_rd=6 Then prefs_error=False
  403.           EndIf
  404.         EndIf
  405.       EndIf
  406.       CloseFile 0
  407.     EndIf
  408.   EndIf
  409. ;Else
  410. ;  prefs_error=False
  411. ;EndIf
  412.  
  413. If prefs_error=True
  414.   If prevsversion=0
  415.     x$="Analogue Joystick Prefs File Not Found."
  416.     x$+Chr$(10)+"You will not  be able to use one"
  417.   Else
  418.     x$="Analogue Joystick Prefs Version is "
  419.     x$+Str$(prevsversion)+".(Version 1 expected)"
  420.   EndIf
  421.   dummy=RTEZRequest("Analogue Joystick Info",x$,"OK|INFO")
  422.   If dummy=0
  423.     dummy2=RTEZRequest("What You should do:","Download and run AnJoyPrefs.lha from Aminet","OK")
  424.   EndIf
  425. EndIf
  426. oxx.w=0
  427. oyy.w=0
  428. ;mx.w=623
  429. ;my.w=490
  430. ;nx.w=682
  431. ;ny.w=524
  432. sx.w=0
  433. sy.w=0
  434. cx=cx/2
  435. cy=cy/2
  436.  
  437.  
  438. ;control_method=1
  439. Dim hood.w(10)
  440. Dim polybuff.w(32)
  441. Dim wpbuff.l(10)
  442. ;35,150,250,285,
  443.  
  444. If AvailMem_(#MEMF_LARGEST|#MEMF_FAST)>(1024*1024)
  445.   Dim slippery.b(1024,1024)
  446. Else
  447.   Goto _nofast
  448. EndIf
  449. If AvailMem_(#MEMF_LARGEST|#MEMF_FAST)>(256*512)
  450.   Dim heightmap.w(256,256)
  451. Else
  452.   Goto _nofast
  453. EndIf
  454.  
  455. hood(0)=70
  456. hood(1)=150
  457. hood(2)=250
  458. hood(3)=150
  459. hood(4)=320
  460. hood(5)=160
  461. hood(6)=0
  462. hood(7)=160
  463.  
  464. hoodp.l=&hood(0)
  465. NEWTYPE .pnt
  466.   sx.w
  467.   sy.w
  468.   app.w
  469. End NEWTYPE
  470.  
  471. NEWTYPE .qpnt
  472.   sx.q
  473.   sy.q
  474.   app.w
  475. End NEWTYPE
  476.  
  477. DEFTYPE .pnt botleftpnt
  478. DEFTYPE .pnt botrightpnt
  479.  
  480. botleftpnt\sx=0
  481. botleftpnt\sy=200
  482. botleftpnt\app=1
  483. botrightpnt\sx=320
  484. botrightpnt\sy=200
  485. botrightpnt\app=1
  486.  
  487. NEWTYPE .ln
  488.   *l1.pnt
  489.   *l2.pnt
  490.   col.w
  491. End NEWTYPE
  492.  
  493. NEWTYPE .plg
  494.  
  495.   *p1.pnt
  496.   *p2.pnt
  497.   *p3.pnt
  498.   *p4.pnt
  499.   col.w
  500. End NEWTYPE
  501. NEWTYPE .ipol
  502.   p1.w
  503.   p2
  504.   p3
  505.   p4
  506. End NEWTYPE
  507.  
  508. NEWTYPE .wheel
  509.   w.q
  510.   u.q
  511.   nt.q
  512.   a
  513. End NEWTYPE
  514.  
  515. DEFTYPE.wheel wheel
  516.  
  517.  
  518. NEWTYPE .rep
  519.   x.q:y:z
  520.   ax:ay:az
  521.   e_freq
  522.   e_vol
  523.   t_freq
  524.   t_vol
  525.   t_snd.b
  526.   xtra.b
  527. End NEWTYPE
  528.  
  529. Dim sincache.w(16)
  530.  
  531. If AvailMem_(#MEMF_LARGEST|#MEMF_FAST)>(16384*4*4)
  532.   Dim px(16384),py(16384),pz(16384),point_value(16384)
  533. Else
  534.   Goto _nofast
  535. EndIf
  536.  
  537. If AvailMem_(#MEMF_LARGEST|#MEMF_FAST)>(16384*4*3)
  538.   Dim ox.q(16384),oy.q(16384),oz.q(16384)
  539. Else
  540.   Goto _nofast
  541. EndIf
  542.  
  543. If AvailMem_(#MEMF_LARGEST|#MEMF_FAST)>(16384*(SizeOf.pnt))
  544.   Dim pnt.pnt(16384)
  545. Else
  546.   Goto _nofast
  547. EndIf
  548.  
  549. If AvailMem_(#MEMF_LARGEST|#MEMF_FAST)>(16384*(SizeOf.qpnt))
  550.   Dim qpnt.qpnt(16384)
  551. Else
  552.   Goto _nofast
  553. EndIf
  554.  
  555. If AvailMem_(#MEMF_LARGEST|#MEMF_FAST)>(16384)
  556.   Dim oapp.b(16384)
  557. Else
  558.   Goto _nofast
  559. EndIf
  560.  
  561. If AvailMem_(#MEMF_LARGEST|#MEMF_FAST)>(16384*(SizeOf.ln))
  562.   Dim lin.ln(16384)
  563. Else
  564.   Goto _nofast
  565. EndIf
  566.  
  567. If AvailMem_(#MEMF_LARGEST|#MEMF_FAST)>(16384*(SizeOf.plg))
  568.   Dim pol.plg(16384)
  569. Else
  570.   Goto _nofast
  571. EndIf
  572.  
  573. If AvailMem_(#MEMF_LARGEST|#MEMF_FAST)>(16384*(SizeOf.ipol))
  574.   Dim ipol.ipol(16384)
  575. Else
  576.   Goto _nofast
  577. EndIf
  578.  
  579. If AvailMem_(#MEMF_LARGEST|#MEMF_FAST)>(16384*2*(SizeOf.rep))
  580.   Dim replay.rep(1000)
  581.   Dim cpurep.rep(1000)
  582. Else
  583.   Goto _nofast
  584. EndIf
  585.  
  586.  
  587. rep_point.l=0
  588.  
  589. NEWTYPE .vobj
  590.   x.q:y:z
  591.   ax:ay:az
  592.   obj_start.w
  593.   obj_end.w
  594.  
  595. End NEWTYPE
  596. If AvailMem_(#MEMF_LARGEST|#MEMF_FAST)>(16384)
  597.  
  598.   Dim vec_obj.vobj(10)
  599.  
  600.   Dim obx(200),oby(200),obz(200)
  601.   Dim robx(200),roby(200),robz(200)
  602.   Dim obln(200,2)
  603.   Dim obpol(200,4),obpolcol(200),obpolnorm(200)
  604.   Dim col_list.w(32,32)
  605. Else
  606.   Goto _nofast
  607. EndIf
  608.  
  609.  
  610. Restore obj_data
  611. For n=1 To 23
  612.   Read xq.q,yq.q,zq.q
  613.   obx(n)=xq;*4
  614.   oby(n)=yq;*4
  615.   obz(n)=zq;*4
  616. Next n
  617.  
  618. Restore line_data
  619. For n=1 To 20
  620.   Read obln(n,1),obln(n,2)
  621. Next n
  622.  
  623. #CAR_POLYS=19
  624. Restore poly_data
  625. For n=1 To #CAR_POLYS
  626.  
  627.   For m=1 To 4
  628.     Read obpol(n,m)
  629.   Next m
  630.   Read obpolcol(n),obpolnorm(n)
  631. Next n
  632.  
  633. ;Restore wheel_obj_data
  634. ;For n=15 To 22
  635. ;  Read xq.q,yq.q,zq.q
  636. ;  obx(n)=xq
  637. ;  oby(n)=yq
  638. ;  obz(n)=zq
  639. ;Next n
  640. ;Restore wheel_poly_data
  641. ;For n=12 To 17
  642. ;  For m=1 To 4
  643. ;    Read obpol(n,m)
  644. ;  Next m
  645. ;  Read obpolcol(n)
  646. ;Next n
  647. ;
  648. ;
  649. ;Restore wheel_obj_data
  650. ;For n=23 To 30
  651. ;  Read xq.q,yq.q,zq.q
  652. ;  obx(n)=xq
  653. ;  oby(n)=yq
  654. ;  obz(n)=zq
  655. ;Next n
  656. ;Restore wheel_poly_data
  657. ;For n=18 To 23
  658. ;  For m=1 To 4
  659. ;    Read obpol(n,m)
  660. ;  Next m
  661. ;  Read obpolcol(n)
  662. ;Next n
  663. ;
  664. ;
  665. ;Restore wheel_obj_data
  666. ;For n=24 To 29
  667. ;  Read xq.q,yq.q,zq.q
  668. ;  obx(n)=xq
  669. ;  oby(n)=yq
  670. ;  obz(n)=zq
  671. ;Next n
  672. ;Restore wheel_poly_data
  673. ;For n=12 To 17
  674. ;  For m=1 To 4
  675. ;    Read obpol(n,m)
  676. ;  Next m
  677. ;  Read obpolcol(n)
  678. ;Next n
  679. ;
  680. ;
  681. ;Restore wheel_obj_data
  682. ;For n=39 To 46
  683. ;  Read xq.q,yq.q,zq.q
  684. ;  obx(n)=xq
  685. ;  oby(n)=yq
  686. ;  obz(n)=zq
  687. ;Next n
  688. ;Restore wheel_poly_data
  689. ;For n=30 To 35
  690. ;  For m=1 To 4
  691. ;    Read obpol(n,m)
  692. ;  Next m
  693. ;  Read obpolcol(n)
  694. ;Next n
  695. ;
  696.  
  697.  
  698. vec_obj(0)\x=100
  699. vec_obj(0)\y=-10000
  700. vec_obj(0)\z=-10
  701. vec_obj(0)\ax=0
  702. vec_obj(0)\ay=0
  703. vec_obj(0)\az=0
  704. vec_obj(0)\obj_start=1
  705. vec_obj(0)\obj_end=23
  706.  
  707. For n=1 To 4
  708. vec_obj(n)\x=vec_obj(0)\x
  709. vec_obj(n)\y=vec_obj(0)\y
  710. vec_obj(n)\z=vec_obj(0)\z
  711. vec_obj(n)\ax=vec_obj(0)\ax
  712. vec_obj(n)\ay=vec_obj(0)\ay
  713. vec_obj(n)\az=vec_obj(0)\az
  714.  
  715. Next n
  716.  
  717. vec_obj(n)\obj_start=15
  718. vec_obj(n)\obj_end=22
  719.  
  720. vec_obj(n)\obj_start=23
  721. vec_obj(n)\obj_end=30
  722.  
  723. vec_obj(n)\obj_start=31
  724. vec_obj(n)\obj_end=38
  725.  
  726. vec_obj(n)\obj_start=39
  727. vec_obj(n)\obj_end=46
  728.  
  729.  
  730. .obj_data
  731. ;front
  732. Data -15,30,10
  733. Data 15,30,10
  734. Data 18,25,7
  735. Data -18,25,7
  736. ;windshield
  737. Data -17,5,3
  738. Data 17,5,3
  739. Data 15,-5,-6
  740. Data -15,-5,-6
  741. ;back
  742. Data 15,-20,-8
  743. Data -15,-20,-8
  744. Data -17,-30,4
  745. Data 17,-30,4
  746. Data 17,-30,10
  747. Data -17,-30,10
  748. ;xtra_front
  749. Data 18,12,3
  750. Data -18,12,3
  751. Data -18,14,3
  752. Data 18,14,3
  753. Data -1,25,4
  754. Data 1,25,4
  755. Data 1,5,2
  756. Data -1,5,2
  757. Data 0,13,3
  758.  
  759. wheel_obj_data:
  760.  
  761. ;wheel
  762. Data -4,  6, 6
  763. Data  4,  6, 6
  764. Data  4, -6, 6
  765. Data -4, -6, 6
  766. Data -4,  6, 12
  767. Data  4,  6, 12
  768. Data  4, -6, 12
  769. Data -4, -6, 12
  770.  
  771. .line_data
  772. ;front
  773. Data 1,2,2,3,3,4,4,1
  774. ;sides
  775. Data 1,11
  776. Data 2,12
  777. Data 4,11
  778. Data 3,12
  779. ;front top
  780. Data 3,6
  781. Data 4,5
  782. Data 5,8
  783. Data 6,7
  784. ;back
  785. Data 7,9
  786. Data 8,10
  787. Data 10,11
  788. Data 9,12
  789. Data 9,10
  790. Data 11,12
  791. Data 5,6
  792. Data 7,8
  793.  
  794. .poly_data
  795.  
  796.  
  797.  
  798. Data 1,2,3,4,     1,0
  799. ;Data 4,3,6,5,2
  800. Data 4,3,19,20,   1,0
  801. Data 4,19,23,16,  2,0
  802. Data 20,3,15,23,  2,0
  803. Data 23,18,6,21,  2,0
  804. Data 17,23,22,5,  2,0
  805.  
  806. Data 16,15,18,17, 1,0
  807. Data 19,20,21,22, 1,0
  808.  
  809.  
  810. Data 1,4,10,14,   2,1
  811. Data 13,9,3,2,    2,1
  812.  
  813. ;Data 5,6,7,8,    3,0
  814. Data 5,22,7,8,    3,0
  815. Data 21,6,7,8,    3,0
  816. Data 22,21,7,8,   3,0
  817. Data 5,8,10,11,   3,0;4
  818. Data 12,9,7,6,    3,0;4
  819.  
  820. Data 8,7,9,10,    2,0
  821. Data 12,11,10,9,  1,0
  822. Data 11,12,13,14, 1,0
  823. Data 14,13,2,1,   1,0
  824.  
  825.  
  826.  
  827.  
  828. wheel_poly_data:
  829. ;Data 2,3,4,5,1
  830. ;Data 9,8,7,6,1
  831. ;Data 5,4,8,9,1
  832. ;Data 7,6,3,2,1
  833. ;Data 2,5,9,6,2
  834. ;Data 7,8,4,3,2
  835.  
  836. Data 15,16,17,18,1
  837. Data 22,21,20,19,1
  838. Data 18,17,21,22,1
  839. Data 20,19,16,15,1
  840. Data 15,18,22,19,2
  841. Data 20,21,17,16,2
  842.  
  843.  
  844. points=0
  845.  
  846. vx=0:vy=-10000:vz=-10
  847. vux=0:vuy=0:vuz=0
  848. vax=0:vaz=.5:vay=0
  849. max_value=3
  850. p2.q=2*Pi
  851. p1.q=Pi
  852. ph.q=Pi/2
  853.  
  854.  
  855. .SETUP
  856.  
  857. If AvailMem_(#MEMF_LARGEST|#MEMF_FAST)<65536
  858.   Goto _nofast
  859. EndIf
  860.  
  861. camera_type=0
  862. mountain=1
  863. autochangegear.w=0
  864. turbosound.w=64
  865. Dim turbosounddata.w(255)
  866. Dim startsounddata.w(255)
  867.  
  868. For tempw.w=0 To 255
  869.   turbosounddata(tempw)=Sin(tempw/8)*32+Sin(tempw/4)*16+Sin(tempw/2)*8
  870.  
  871.   startsounddata(tempw)=Sin(tempw/64)/(tempw+1)
  872.   turbosound=-turbosound
  873. Next tempw
  874.  
  875. Dim oengfreqa(51)
  876. Dim oengvola(51)
  877. echoa.w=0
  878. echola.w=1
  879. ;Misc Constants
  880. ;~~~~~~~~~~~~~~
  881. #WINWIDTH=640
  882. #WINHEIGHT=320
  883. #MOUSECTRL=0
  884. #ANJOYCTRL=1
  885. #KEYSCTRL=2
  886. #DIJOYCTRL=3
  887. #CPUCTRL1=4
  888.  
  889. generate_new_track=True
  890.  
  891.  
  892. ;gadget tags
  893. ;===========
  894.  
  895. #tag=$80080000
  896. #GTCY_Active=#tag+15
  897. #GTSL_Level=#tag+40
  898.  
  899.  
  900. ;gadget text constants
  901.  
  902. #TXT_LEFT=$1
  903. #TXT_RIGHT=$2
  904. #TXT_ABOVE=$4
  905. #TXT_BELOW=$8
  906. #TXT_IN=$10
  907.  
  908.  
  909. ;gadget id constants
  910.  
  911. #CAR_G=11
  912. #SENSE_G=1
  913. #RIDE_G=2
  914. #ZOOM_G=10
  915.  
  916.  
  917. #TRACK_G=3
  918. #TURNS_G=4
  919. #OVAL_G=5
  920. #BUMP_G=6
  921.  
  922. #OK_G=7
  923. #QUIT_G=8
  924. #NEWTRACK_G=9
  925.  
  926. #ENGDSP_G=12
  927. #HCOLOR_G=13
  928. #THRHELP_G=14
  929. #MOUSESENSE_G=15
  930. #DISTANCE_G=16
  931. #CONTROL_G=17
  932. #GAMETYPE_G=18
  933. #TLENGTH_G=19
  934. #HILLS_G=20
  935. #LANDSCAPE_G=21
  936. #TURN_LAND_G=22
  937. #GRAVITY_G=23
  938. #MOUSE_RET_G=24
  939. #MANUAL_G=25
  940. #EASYDRIVE_G=26
  941. #VIEWCAR_G=27
  942. #FLATROAD_G=28
  943. #NTSCPAL_G=29
  944. #FRAME_RATE_COR_G=30
  945. #WING_STRENGTH_G=31
  946. #F_MULTI_G=32
  947. #ANJ_INV_G=33
  948.  
  949. WbToScreen 0
  950. ShowScreen 0
  951.  
  952. If ScreenWidth<#WINWIDTH OR ScreenHeight<#WINHEIGHT
  953.   Free Screen 0
  954.   Screen 0,0,0,#WINWIDTH,#WINHEIGHT,2,$8000,"Wreckage "+version$+", "+copyright$+" Christos Dimitrakakis",2,1
  955.   ShowScreen 0
  956. EndIf
  957.  
  958.  
  959. GTSlider 0,#MOUSE_RET_G,20,120,140,12,"Steering Return",#TXT_ABOVE,0,100,50
  960.  
  961. GTCycle 0,#NTSCPAL_G,0,156,200,12,"Refresh Rate",#TXT_ABOVE,"50Hz (PAL)|60Hz (NTSC)"
  962.  
  963. GTCycle 0,#CONTROL_G,0,188,200,12,"Control Method",#TXT_ABOVE,"Mouse|Analogue Joystick|Keyboard|Digital Joystick"
  964.  
  965. GTSlider 0,#TLENGTH_G,480,80,140,12,"Track Length",#TXT_ABOVE,100,300,150
  966. GTSlider 0,#HILLS_G,480,116,140,12,"Hill Steepness",#TXT_ABOVE,0,100,50
  967.  
  968. GTCycle 0,#CAR_G,480,30,140,12,"Car",#TXT_ABOVE,"Audi|BMW|Lancia|Toyota|Ferrari|Porsche|McF1|F1|Jeep"
  969. GTButton 0,#VIEWCAR_G,480,48,140,12,"View Car",#TXT_IN
  970.  
  971. GTSlider 0,#SENSE_G,20,90,200,10,"Speed Sensitive Steering %",#TXT_ABOVE,0,100,50
  972. GTSlider 0,#MOUSESENSE_G,20,60,200,10,"Mouse Sensitivity %",#TXT_ABOVE,0,10,5
  973. GTSlider 0,#RIDE_G,120,30,100,10,"Ride Height",#TXT_ABOVE,0,10,5
  974. GTSlider 0,#ZOOM_G,0,30,100,10,"Zoom",#TXT_ABOVE,7,13,8
  975.  
  976.  
  977. GTSlider 0,#TRACK_G,240,30,100,10,"Track Grip",#TXT_ABOVE,0,100,50
  978. GTSlider 0,#TURNS_G,360,30,100,10,"Curve Steepness",#TXT_ABOVE,0,100,50
  979. GTSlider 0,#OVAL_G,240,60,100,10,"Circle %",#TXT_ABOVE,0,100,50
  980. GTSlider 0,#BUMP_G,360,60,100,10,"Bump height",#TXT_ABOVE,0,5,1
  981. GTSlider 0,#GRAVITY_G,240,92,200,12,"Gravity",#TXT_ABOVE,10,150,100
  982.  
  983. GTButton 0,#OK_G,60,232,40,20,"PLAY",#TXT_IN
  984.  
  985. GTButton 0,#QUIT_G,160,232,40,20,"QUIT",#TXT_IN
  986.  
  987. GTButton 0,#NEWTRACK_G,240,116,200,20,"GENERATE NEW TRACK",#TXT_IN
  988.  
  989. GTCheckBox 0,#ENGDSP_G,240,136,100,10,"Engine DSP",#TXT_RIGHT
  990. GTCheckBox 0,#HCOLOR_G,240,152,100,10,"More Colours",#TXT_RIGHT
  991. GTCheckBox 0,#THRHELP_G,240,168,100,10,"Throttle Help",#TXT_RIGHT
  992. GTCheckBox 0,#LANDSCAPE_G,240,184,100,10,"Landscape on",#TXT_RIGHT
  993. GTCheckBox 0,#MANUAL_G,240,200,100,10,"Manual Gears",#TXT_RIGHT
  994. GTCheckBox 0,#EASYDRIVE_G,240,216,100,10,"Easy Driving",#TXT_RIGHT
  995. GTCheckBox 0,#FLATROAD_G,240,232,100,10,"Flat Around Track",#TXT_RIGHT
  996. GTCheckBox 0,#FRAME_RATE_COR_G,240,248,100,10,"Frame rate correction",#TXT_RIGHT
  997. GTCheckBox 0,#ANJ_INV_G,240,264,100,10,"Invert Analog Joystick",#TXT_RIGHT
  998. GTSlider 0,#DISTANCE_G,480,152,140,12,"Distancing",#TXT_ABOVE,25,200,100
  999. GTSlider 0,#TURN_LAND_G,480,188,140,12,"Inclined Turns",#TXT_ABOVE,0,100,25
  1000. GTSlider 0,#WING_STRENGTH_G,480,224,140,12,"Wing Strength",#TXT_ABOVE,100,400,100
  1001. GTSlider 0,#F_MULTI_G,480,264,140,12,"Force Multiplier",#TXT_ABOVE,100,400,100
  1002.  
  1003. Window 0,0,0,#WINWIDTH,#WINHEIGHT,2|4,"Wreckage Experimental Rev."+version$+", Christos Dimitrakakis 1998",2,1
  1004. AttachGTList 0,0
  1005. ;GTDisable 0,#NEWTRACK_G
  1006. Use Window 0
  1007. Activate 0
  1008. ;tempw.w=RTEZRequest ("Copyright (C) 1997 Christos Dimitrakakis","This Game is FreeWare","OK")
  1009. ;NPrint "This game is Freeware"
  1010. ;NPrint ""
  1011. ;NPrint "ENTER FRAME SPEED"
  1012. frame_speed=.5;Edit(1,2)/2
  1013.  
  1014. rw_drive=False
  1015. fw_drive=False
  1016. FR_drive=False
  1017.  
  1018. Dim gear_ratio1(10)
  1019.  
  1020.  
  1021. select_cars:
  1022.  
  1023. no_choice_made=False
  1024. ;car_choice=Edit(2,2)
  1025.  
  1026. easy_drive=False
  1027. auto_gears=True
  1028. track_grip=.5
  1029. max_turns=.125
  1030. oval_track=.5
  1031. bumps=True
  1032. bump_height=.5
  1033. S_STEERING=True
  1034. ss_sensitivity=.25
  1035. driver_height=2
  1036. zoom_factor.b=8
  1037. car_choice=1
  1038. engine_dsp=False
  1039. nofbitplanes=2
  1040. throttle_help=False
  1041. mouse_sensitivity=2.5
  1042. max_distancing=5000
  1043. point_distancing=50
  1044. total_track_length=150
  1045. hill_height=0.25
  1046. landscape_on=False
  1047. inclined_turns=.5
  1048. mouse_return_rate=.5
  1049. gravity=1
  1050. ntsc_mode=True
  1051. frame_rate_correction=False
  1052. old_vux=0
  1053. old_vuy=0
  1054. old_vuz=0
  1055. wing_strength_adj=1
  1056. f_multiplier=1
  1057. anj_inverse=False
  1058. ;Gosub road
  1059.  
  1060. ;Gosub horizon
  1061. generate_new_track=True
  1062.  
  1063.  
  1064. .myGUI
  1065.   FlushEvents
  1066.     engfreq=200
  1067.     gear=0
  1068.     map_slip=0
  1069.     vx=0:vy=-10000:vz=mountain*land1{vx,vy}-11
  1070.     vux=0:vuy=1:vuz=0
  1071.     vax=0:vaz=.5:vay=0
  1072.     ovux=0:ovuy=0:ovuz=0
  1073.     rux=0:orux=0
  1074.     ruy=0:oruy=0
  1075.     cvaz=Cos(vaz)
  1076.     svaz=Sin(vaz)
  1077.     cvay=Cos(vay)
  1078.     svay=Sin(vay)
  1079.     cvax=Cos(vax)
  1080.     svax=Sin(vax)
  1081.     susp1=0:susp2=0:susp3=0:susp4=0
  1082.     osusp1=0:osusp2=0:osusp3=0:osusp4=0
  1083.     wz=0
  1084.     vwz=0
  1085.     forceonx2=0:downforce=0
  1086.     Force_on_X=0
  1087.     Force_on_Z=0
  1088.  
  1089.     upside_down=False
  1090.     vec_obj(0)\x=100
  1091.     vec_obj(0)\y=-10000
  1092.     vec_obj(0)\z=0
  1093.     vec_obj(0)\ax=0
  1094.     vec_obj(0)\ay=0
  1095.     vec_obj(0)\az=0
  1096.     racing=True
  1097.     LoopSound 4,8,0
  1098.     point_start=0:point_end=points1-1
  1099.     point_min=1
  1100.     point_max=points1
  1101.     start_point=1
  1102.     end_point=points1
  1103.     closest_point=1
  1104.   rep_point=0
  1105.  
  1106.  
  1107.  
  1108.  
  1109. Use Window 0
  1110. WindowOutput 0
  1111. ;WLocate 1,1
  1112. ;NPrint "FPS%:",100*nofcounts/nofframes,"   "
  1113. exit_gui.b=False
  1114. quit_game.b=False
  1115. ;Filter Off
  1116. Repeat
  1117.   ev.l=WaitEvent
  1118.  
  1119.   Select ev
  1120.     Case $40
  1121.       Select EventWindow
  1122.         Case 0
  1123.           Select GadgetHit
  1124.             Case #CAR_G
  1125.               tempw.w=EventCode
  1126.               WLocate 1,1:NPrint "car: ",tempw,"  "
  1127.               car_choice=tempw+1
  1128.  
  1129.             Case #VIEWCAR_G
  1130.               Gosub view_car
  1131.  
  1132.  
  1133.             Case #SENSE_G
  1134.               tempw.w=EventCode
  1135.               WLocate 1,1:NPrint "SSS: ",tempw,"  "
  1136.               ss_sensitivity=tempw/200
  1137.  
  1138.             Case #MOUSESENSE_G
  1139.               tempw.w=EventCode
  1140.               WLocate 1,1:NPrint "SENS: ",tempw," "
  1141.               mouse_sensitivity=tempw/2
  1142.  
  1143.             Case #RIDE_G
  1144.               tempw.w=EventCode
  1145.               WLocate 1,1:NPrint "Ride: ",tempw,"  "
  1146.               driver_height=tempw
  1147.  
  1148.             Case #ZOOM_G
  1149.               tempw.w=EventCode
  1150.               WLocate 1,1:NPrint "Zoom: ",tempw,"  "
  1151.               zoom_factor.b=tempw
  1152.  
  1153.             Case #TRACK_G
  1154.               tempw.w=EventCode
  1155.               WLocate 1,1:NPrint "Grip: ",tempw,"  "
  1156.               track_grip=tempw/100
  1157.  
  1158.             Case #TURNS_G
  1159.               tempw.w=EventCode
  1160.               WLocate 1,1:NPrint "Turns: ",tempw,"  "
  1161.               max_turns=tempw/400
  1162.  
  1163.             Case #TURN_LAND_G
  1164.               tempw.w=EventCode
  1165.               WLocate 1,1:NPrint "Inclined: ",tempw,"  "
  1166.               inclined_turns=tempw/100
  1167.  
  1168.             Case #BUMP_G
  1169.               tempw.w=EventCode
  1170.               WLocate 1,1:NPrint "Bumps: ",tempw,"  "
  1171.               bump_height=tempw/2
  1172.  
  1173.             Case #OVAL_G
  1174.               tempw.w=EventCode
  1175.               WLocate 1,1:NPrint "Oval: ",tempw,"  "
  1176.               oval_track=tempw/100
  1177.  
  1178.             Case #OK_G
  1179.               exit_gui=True
  1180.  
  1181.             Case #QUIT_G
  1182.               exit_gui=True
  1183.               quit_game=True
  1184.  
  1185.             Case #FLATROAD_G
  1186.               tempw.w=EventCode
  1187.               generate_new_track=True
  1188.               If tempw=1
  1189.                 flat_road=True
  1190.               Else
  1191.                 flat_road=False
  1192.               EndIf
  1193.  
  1194.             Case #NEWTRACK_G
  1195.               generate_new_track=True
  1196.  
  1197.             Case #ENGDSP_G
  1198.               tempw.w=EventCode
  1199.               WLocate 1,1:NPrint "DSP: ",tempw," "
  1200.               If tempw=1
  1201.                 engine_dsp=True
  1202.               Else
  1203.                 engine_dsp=False
  1204.               EndIf
  1205.  
  1206.             Case #HCOLOR_G
  1207.               tempw.w=EventCode
  1208.               WLocate 1,1:NPrint "HCOL: ",tempw,"  "
  1209.               If tempw=1
  1210.                 generate_new_track=True
  1211.                 nofbitplanes=5
  1212.               Else
  1213.                 generate_new_track=True
  1214.                 nofbitplanes=2
  1215.               EndIf
  1216.  
  1217.             Case #THRHELP_G
  1218.               tempw.w=EventCode
  1219.               WLocate 1,1:NPrint "THLP: ",tempw,"   "
  1220.               If tempw=1
  1221.                 throttle_help=True
  1222.               Else
  1223.                 throttle_help=False
  1224.               EndIf
  1225.  
  1226.             Case #LANDSCAPE_G
  1227.               tempw.w=EventCode
  1228.               WLocate 1,1:NPrint "LAND: ",tempw,"   "
  1229.               If tempw=1
  1230.                 landscape_on=True
  1231.               Else
  1232.                 landscape_on=False
  1233.               EndIf
  1234.  
  1235.             Case #MANUAL_G
  1236.               tempw.w=EventCode
  1237.               WLocate 1,1:NPrint "MANU: ",tempw,"   "
  1238.               If tempw=1
  1239.                 auto_gears=False
  1240.               Else
  1241.                 auto_gears=True
  1242.               EndIf
  1243.  
  1244.             Case #EASYDRIVE_G
  1245.               tempw.w=EventCode
  1246.               WLocate 1,1:NPrint "EASY: ",tempw,"    "
  1247.               If tempw=1
  1248.                 easy_drive=True
  1249.               Else
  1250.                 easy_drive=False
  1251.               EndIf
  1252.  
  1253.             Case #DISTANCE_G
  1254.               tempw.w=EventCode
  1255.               WLocate 1,1:NPrint "DIST: ",tempw,"  "
  1256.               max_distancing=50*tempw
  1257.               point_distancing=tempw/2
  1258.  
  1259.             Case #CONTROL_G
  1260.               tempw.w=EventCode
  1261.               WLocate 1,1:NPrint "DIST: ",tempw,"  "
  1262.  
  1263.               If tempw=#ANJOYCTRL AND prefs_error=True
  1264.                 If prevsversion=0
  1265.                   x$="Analogue Joystick Prefs File Not Found."
  1266.                   x$+Chr$(10)+"You will not  be able to use one"
  1267.                 Else
  1268.                   x$="Analogue Joystick Prefs Version is "
  1269.                   x$+Str$(prevsversion)+".(Version 1 expected)"
  1270.                 EndIf
  1271.                 dummy=RTEZRequest("Analogue Joystick Info",x$,"OK|INFO")
  1272.                 If dummy=0
  1273.                   dummy2=RTEZRequest("What You should do:","Download and run AnJoyPrefs.lha from Aminet","OK")
  1274.                 EndIf
  1275.                 tempw=control_method
  1276.                 GTSetAttrs 0,#CONTROL_G,#GTCY_Active,tempw
  1277.               EndIf
  1278.  
  1279.               control_method=tempw
  1280.  
  1281.             Case #TLENGTH_G
  1282.               tempw.w=EventCode
  1283.               WLocate 1,1:NPrint "TLEN: ",tempw,"  "
  1284.               total_track_length=tempw
  1285.  
  1286.             Case #HILLS_G
  1287.               tempw.w=EventCode
  1288.               WLocate 1,1:NPrint "HILL: ",tempw,"  "
  1289.               hill_height=tempw/200
  1290.               f1.f=((Rnd)+.2)*hill_height*4
  1291.               f2.f=((Rnd)+.2)*hill_height*3
  1292. ;              dummy=RTEZRequest("hill "+Str$(hill_height),Str$(f1)+","+Str$(f2),"OK")
  1293.  
  1294.             Case #GRAVITY_G
  1295.               tempw.w=EventCode
  1296.               WLocate 1,1:NPrint "GRAV: ",tempw,"  "
  1297.               gravity=tempw/100
  1298.  
  1299.             Case #MOUSE_RET_G
  1300.               tempw.w=EventCode
  1301.               WLocate 1,1:NPrint "MRET: ",tempw,"  "
  1302.               mouse_return_rate=tempw/100
  1303.  
  1304.             Case #NTSCPAL_G
  1305.               tempw.w=EventCode
  1306.               WLocate 1,1:NPrint "NTSC: ",tempw,"  "
  1307.               ntsc_mode=tempw.w
  1308.             Case #FRAME_RATE_COR_G
  1309.               tempw.w=EventCode
  1310.               WLocate 1,1:NPrint "FRCR: ",tempw,"  "
  1311.               If tempw=1
  1312.                 frame_rate_correction=True
  1313.               Else
  1314.                 frame_rate_correction=False
  1315.               EndIf
  1316.  
  1317.             Case #WING_STRENGTH_G
  1318.               tempw.w=EventCode
  1319.               WLocate 1,1:NPrint "WING: ",tempw,"  "
  1320.               wing_strength_adj=tempw/100
  1321.  
  1322.             Case #F_MULTI_G
  1323.               tempw.w=EventCode
  1324.               WLocate 1,1:NPrint "FMUL: ",tempw,"  "
  1325.               f_multiplier=tempw/100
  1326.  
  1327.             Case #ANJ_INV_G
  1328.               tempw.w=EventCode
  1329.               WLocate 1,1:NPrint "INV: ",tempw,"  "
  1330.               If tempw=1
  1331.                 anj_inverse=True
  1332.               Else
  1333.                 anj_inverse=False
  1334.               EndIf
  1335.  
  1336.  
  1337.           End Select
  1338.       End Select
  1339.   End Select
  1340.  
  1341.  
  1342. Until exit_gui=True
  1343.  
  1344. If quit_game=True Then Goto finish2
  1345.  
  1346. ;Filter On
  1347.  
  1348. Gosub select_car
  1349.  
  1350. If easy_drive=True
  1351. ;  HPower*1.5
  1352.   wing_strength*2
  1353.   drag_factor*.5
  1354. EndIf
  1355. upside_down=False
  1356. rep_point=0
  1357. .Main_Code
  1358.  
  1359. If file_missing=True
  1360.   dummy=RTEZRequest("OK?","Not realy","OK")
  1361. EndIf
  1362.  
  1363. Free Sound 1
  1364. Free Sound 4
  1365. Free Sound 7
  1366.  
  1367. safe_loadsound {1,"SFX/"+engined$}
  1368. safe_loadsound {4,"SFX/"+engined$}
  1369. safe_loadsound {7,"SFX/"+turbod$}
  1370.  
  1371. Gosub reset_car
  1372.  
  1373. ;dummy=RTEZRequest("OK","OK","OK")
  1374. If file_missing=True Then Goto finish3
  1375. ;dummy=RTEZRequest("OK","OK","OK")
  1376. DEFTYPE .sound *mysound
  1377.  
  1378. If Bank(#TURBOCACHE)
  1379.   FreeBank #TURBOCACHE
  1380. EndIf
  1381.  
  1382. If Bank(#SOUNDCACHE)
  1383.   FreeBank #SOUNDCACHE
  1384. EndIf
  1385.  
  1386. *mysound=Addr Sound(7)
  1387.  
  1388. InitBank #TURBOCACHE,*mysound\_length*2,65536
  1389.  
  1390. If BankSize(#TURBOCACHE)<*mysound\_length*2
  1391.   dummy=RTEZRequest("#TURBOCACHE","Bank too small","OK")
  1392.   Goto finish3
  1393. EndIf
  1394.  
  1395.  
  1396.  
  1397.  
  1398. *mysound=Addr Sound(4)
  1399.  
  1400. InitBank #SOUNDCACHE,*mysound\_length*2,65536
  1401.  
  1402. If BankSize(#SOUNDCACHE)<*mysound\_length*2
  1403.   dummy=RTEZRequest("#SOUNDCACHE","Bank too small","OK")
  1404.   Goto finish3
  1405. EndIf
  1406.  
  1407. DEFTYPE .sound *othersound
  1408. *othersound=Addr Sound (1)
  1409. If *othersound\_length<*mysound\_length
  1410.   dummy=RTEZRequest("sound 1","Sound 1 too smalL!","OK")
  1411. EndIf
  1412.  
  1413.  
  1414.  
  1415. ;addrl.l=Bank(#SOUNDCACHE)
  1416. ;
  1417. ;For long.l=0 To *mysound\_length*2-2
  1418. ;  SoundData 1,long,PeekSound(4,long)
  1419. ;  Poke.b addrl+long,PeekSound(4,long)
  1420. ;Next long
  1421. ;
  1422. ;addrl.l=Bank(#TURBOCACHE)
  1423. ;For long.l=0 To *mysound\_length*2-2
  1424. ;  Poke.b addrl+long,PeekSound(7,long)
  1425. ;Next long
  1426.  
  1427.  
  1428.  
  1429.  
  1430. Kdoppler=1
  1431. nofcounts=0
  1432. nofframes=0
  1433.  
  1434. If AvailMem_(#MEMF_LARGEST|#MEMF_CHIP)>320*160
  1435.   BitMap 0,320,160,nofbitplanes
  1436.  
  1437. Else
  1438.   Goto _nochip
  1439. EndIf
  1440.  
  1441. If AvailMem_(#MEMF_LARGEST|#MEMF_CHIP)>320*160
  1442.   BitMap 1,320,160,nofbitplanes
  1443. Else
  1444.   Goto _nochip
  1445. EndIf
  1446.  
  1447.  
  1448. CNIF #SYSTEM_FRIENDLY=0
  1449.  
  1450. nofcolours=2^nofbitplanes
  1451. nofframes=0
  1452. onof_frames=0
  1453. frame_speed=.5
  1454. old_vux=0
  1455. old_vuy=0
  1456. old_vuz=0
  1457.  
  1458. BLITZ
  1459. ;Runerrsoff
  1460. Slice 0,44,320,160,$fff8,nofbitplanes,8,nofcolours,320,320
  1461.  
  1462. ;Peek.b 0,32
  1463.  
  1464.  
  1465. ;Screen 1,0,0,640,320,2,$8004,"w",2,1,0
  1466. ;RGB 0,10,10,10
  1467. ;RGB 1,0,0,0
  1468. ;RGB 2,15,0,0
  1469. ;RGB 3,4,5,6
  1470. ;Screen 2,0,0,640,320,2,$8004,"z",2,1,1
  1471.  
  1472. BitMapOutput 0
  1473. Use BitMap 0
  1474. Cls
  1475. Show 0
  1476.  
  1477. If ntsc_mode=1
  1478.   ForceNTSC
  1479. Else
  1480.   ForcePAL
  1481. EndIf
  1482.  
  1483. Locate 10,10
  1484. NPrint "Please wait"
  1485. Show 0
  1486. RGB 0,10,10,10
  1487. RGB 1,0,0,0
  1488. RGB 2,15,0,0
  1489. RGB 3,4,5,6
  1490. If nofcolours>4
  1491.   RGB 0,10,11,12
  1492.   RGB 4,15,15,15
  1493.   RGB 5,12,0,0
  1494.   RGB 6,9,0,0
  1495.   RGB 7,6,0,0
  1496. ;  RGB 7,15,15,15
  1497.   For i=0 To 7
  1498.     RGB i+8,1,i+1,1
  1499.   Next i
  1500.   For i=0 To 15
  1501.     RGB i+16,i*.5,i*.6,i*.7
  1502.   Next i
  1503.   hi_line_col=4
  1504.  
  1505.   col_list(0,31)=4
  1506.   col_list(0,30)=4
  1507.   col_list(0,29)=2
  1508.   col_list(0,28)=5
  1509.   col_list(0,27)=6
  1510.   col_list(0,26)=7
  1511.   col_list(0,25)=7
  1512.   col_list(0,24)=24
  1513.   col_list(0,23)=24
  1514.   col_list(0,22)=24
  1515.   col_list(0,21)=23
  1516.   col_list(0,20)=23
  1517.   col_list(0,19)=23
  1518.   col_list(0,18)=22
  1519.   col_list(0,17)=22
  1520.   col_list(0,16)=22
  1521.   col_list(0,15)=22
  1522.   col_list(0,14)=22
  1523.   col_list(0,13)=21
  1524.   col_list(0,12)=21
  1525.   col_list(0,11)=20
  1526.   col_list(0,10)=20
  1527.   col_list(0,9)=19
  1528.   col_list(0,8)=19
  1529.   col_list(0,7)=18
  1530.   col_list(0,6)=18
  1531.   col_list(0,5)=17
  1532.   col_list(0,4)=17
  1533.   col_list(0,3)=16
  1534.   col_list(0,2)=16
  1535.   col_list(0,1)=1
  1536.   col_list(0,0)=1
  1537.  
  1538.  
  1539. Else
  1540.   hi_line_col=2
  1541. EndIf
  1542.  
  1543. ;ForceNTSC
  1544.   offsetscx.w=160
  1545.   offsetscy.w=80
  1546.  
  1547. CELSE
  1548.   ShowScreen 1
  1549.   Use Screen 1
  1550.   Window 1,0,0,scrx-32,scry-32,$100,"Wreckage",2,1
  1551.   myrastport.l=RastPort(1)
  1552.   offsetscx=scrx/2
  1553.   offsetscy=scry/2
  1554.  
  1555. CEND
  1556.  
  1557.  
  1558.  
  1559. filterfrequency.q=0
  1560.  
  1561. ;RGB 4,5,6,7
  1562. ;RGB 5,6,6,6
  1563. ;RGB 6,5,5,5
  1564. ;RGB 7,12,12,12
  1565.  
  1566. If generate_new_track=True
  1567.   For m=0 To 1024
  1568.       GetReg a0,&slippery(0,m)
  1569.       MOVE.w #1023,d0
  1570.   _asm_slippery:
  1571.       MOVE.b #-1,(a0)+
  1572.       SUBQ.w #1,d0
  1573.       BGE _asm_slippery
  1574.   Next m
  1575.   Gosub clear_landscape
  1576.   Gosub road
  1577.   Gosub horizon
  1578.   generate_new_track=False
  1579.   map_slip=0
  1580.   vx=0:vy=-10000:vz=mountain*land1{vx,vy}-11
  1581. Else
  1582.   polygons=opolygons
  1583.   lines=olines
  1584. EndIf
  1585.  
  1586.  
  1587. *mysound = Addr Sound(4)
  1588.  
  1589. addrl.l=Bank(#SOUNDCACHE)
  1590.  
  1591. For long.l=0 To *mysound\_length*2-2
  1592.   SoundData 1,long,PeekSound(4,long)
  1593.   Poke.b addrl+long,PeekSound(4,long)
  1594. Next long
  1595.  
  1596. *mysound = Addr Sound(7)
  1597.  
  1598. addrl.l=Bank(#TURBOCACHE)
  1599. For long.l=0 To *mysound\_length*2-2
  1600.   Poke.b addrl+long,PeekSound(7,long)
  1601. Next long
  1602.  
  1603.  
  1604. CNIF #SYSTEM_FRIENDLY=0
  1605.  
  1606. Mouse On
  1607. BlitzKeys On
  1608. db=0
  1609. Use BitMap db
  1610. BitMapOutput db
  1611. CEND
  1612.  
  1613. LoopSound 0,1,0
  1614. LoopSound 1,2,0
  1615. ;Gosub sqthing
  1616.  
  1617. olines=lines
  1618. opolygons=polygons
  1619. Dim xqueue(8)
  1620. Dim yqueue(8)
  1621. apoint=8
  1622.  
  1623.  
  1624. point_min=1
  1625. point_max=points1
  1626. start_point=1
  1627. end_point=points1
  1628.  
  1629. CNIF #SYSTEM_FRIENDLY=0
  1630.   SetInt 5
  1631.     nofframes+1
  1632.   End SetInt
  1633. CEND
  1634.  
  1635. engine_pointer.l=0
  1636.  
  1637. power_ratio2=power_ratio
  1638. xx.w=0:yy.w=0
  1639. Repeat
  1640.   x.w=0
  1641.   y.w=0
  1642.  
  1643.  
  1644. ;************************************
  1645. ;*                                  *
  1646. ;*    ANALOGUE JOYSTICK CONTROL     *
  1647. ;*                                  *
  1648. ;************************************
  1649.  
  1650.   If control_method=#ANJOYCTRL
  1651.     VWait                   ;this code should ALWAYS run on type 5 interrupt
  1652.     CNIF #SYSTEM_FRIENDLY=0
  1653.  
  1654.     Show db
  1655.     CEND
  1656.  
  1657.                             ;unless 100% positive that game loop runs
  1658.  
  1659.                             ;in time < 1 frame
  1660.     MOVE.w $dff014,d0       ;get Port1 POT
  1661.     MOVE.b d0,d1            ;move lower byte (X) to d1
  1662.     LSR.w #8,d0             ;shift 8 - now Y is in lower byte
  1663.  
  1664.                             ;(perhaps the MOVE/LSR combo could
  1665.                             ;be replaced with a bitfield instruction?)
  1666.  
  1667.     MOVE.b #1,$dff034       ;dump the capacitors!
  1668.                             ;almost immediately after the VBLANK
  1669.                             ;must read POTX/POTY first, though
  1670.  
  1671.     PutReg d0,y.w           ;put the stuff into place
  1672.     PutReg d1,x.w
  1673.     avx+x-xqueue(apoint)                    ;add them
  1674.     avy+y-yqueue(apoint)
  1675.     xqueue(apoint)=x
  1676.     yqueue(apoint)=y
  1677.     apoint+1
  1678.     If apoint>8 Then apoint=1
  1679.  
  1680.     rx.w=avx-cx
  1681.     ry.w=avy-cy
  1682.  
  1683.     If rx>0 Then Cfx=mx Else Cfx=nx
  1684.     If ry>0 Then Cfy=my Else Cfy=ny
  1685.     If QAbs(rx)<1
  1686.       rx=0
  1687.     Else
  1688.       rx=rx-1*Sgn(rx)
  1689.     EndIf
  1690.  
  1691.     rx_2=rx/Cfx
  1692.     ry_2=ry/Cfy
  1693.  
  1694.     If JAnAanj_inverse=True
  1695.       CalX=16*rx_2
  1696.       CalY=20*ry_2
  1697.     Else
  1698.       CalX=16*rx_2
  1699.       CalY=20*ry_2
  1700.     EndIf
  1701.     If Abs(CalX)<.1 Then CalX=0
  1702.     turn=CalX
  1703.   Else
  1704.  
  1705. ;************************************
  1706. ;*                                  *
  1707. ;*      OTHER CONTROL METHODS       *
  1708. ;*                                  *
  1709. ;************************************
  1710.  
  1711.     Select control_method
  1712.  
  1713.  
  1714. ;MOUSE
  1715. ;=====
  1716.  
  1717.       Case #MOUSECTRL
  1718.  
  1719.         CNIF #SYSTEM_FRIENDLY=0
  1720.         ;turn=(MouseX-160)/10
  1721.         mxspeed=MouseXSpeed
  1722.         ;smsxo=smsx
  1723.         ;smsx=SMouseX
  1724.         mouseturn+mxspeed*mouse_sensitivity/20
  1725.         mouseturn/(1+0.04*mouse_return_rate)
  1726.         turn=mouseturn
  1727.         CELSE
  1728.         turn=(WMouseX-160)/10
  1729.         CEND
  1730.  
  1731.         If ((Joyb(0) AND 2)=2)
  1732.           If throttle_help=False
  1733.             CalY=QLimit(CalY-1,-10,0)
  1734.           Else
  1735.             CalY=(CalY-10)/2
  1736.           EndIf
  1737.         Else
  1738.           CalY=0
  1739.         EndIf
  1740.  
  1741.         If ((Joyb(0)AND 1)=1)
  1742.           CalY=CalY+10
  1743.         EndIf
  1744.  
  1745. ;        If (Joyb(0)=3)
  1746. ;          handbrake=True
  1747. ;        Else
  1748. ;          handbrake=False
  1749. ;        EndIf
  1750.  
  1751.  
  1752. ;DIGITAL JOYSTICK
  1753. ;================
  1754.  
  1755.       Case #DIJOYCTRL
  1756.         digturn=Joyx(1)
  1757.         digaccel=-Joyy(1)
  1758.         If Joyb(1) Then handbrake=True Else handbrake=False
  1759.  
  1760. ;KEYBOARD
  1761. ;========
  1762.  
  1763.       Case #KEYSCTRL
  1764.         digaccel=0:digturn=0
  1765.         If RawStatus($38) Then digturn-1
  1766.         If RawStatus($39) Then digturn+1
  1767.         If RawStatus($63) Then digaccel+1
  1768.         If RawStatus($64) Then digaccel-1
  1769.         If RawStatus($66) Then handbrake=True Else handbrake=False
  1770.  
  1771.       Case #CPUCTRL1
  1772.         turn=cpu_turn
  1773.         CalY=QLimit(-cpu_accel,-10,10)
  1774.  
  1775.     End Select
  1776.     CNIF #SYSTEM_FRIENDLY=0
  1777.     VWait
  1778.     ;ShowScreen db+1
  1779.     Show db
  1780.     CEND
  1781.   EndIf
  1782.  
  1783. ;  VWait
  1784.   db=1-db
  1785.  
  1786.   nofcounts+1
  1787.   donof_frames=nofframes-onof_frames
  1788.   onof_frames=nofframes
  1789.  
  1790.   If frame_rate_correction=False
  1791.     frame_speed=.5
  1792.   Else
  1793.     frame_speed = .2*donof_frames;*nofframes/nofcounts
  1794.     If ntsc_mode=1
  1795.       frame_speed=frame_speed*5/6
  1796.     EndIf
  1797.   EndIf
  1798.  
  1799.   CNIF #SYSTEM_FRIENDLY=0
  1800.   Use BitMap db
  1801.   Cls
  1802.   BitMapOutput db
  1803.  
  1804.   CELSE
  1805.   VWait
  1806.   WCls
  1807.   CEND
  1808.  
  1809. ;  Locate 1,1
  1810. ;  NPrint CalX," ",CalY
  1811.   Gosub filter_input
  1812.   thrust=QLimit(-2*CalY,0,10)
  1813.   Gosub simple_model
  1814.   cached_for_view_vx=vx
  1815.   cached_for_view_vy=vy
  1816.   cached_for_view_vz=vz
  1817.  
  1818.   vz-driver_height-drivfor*Sin(vax);Abs(slopex)
  1819.  
  1820.   vx+drivfor*Sin(vaz)
  1821.   vy+drivfor*Cos(vaz)
  1822.   Gosub move_view
  1823.   Gosub move_objects
  1824.   Gosub move_points
  1825.   Gosub rotate_points
  1826. ;  Gosub calc3d
  1827.   Gosub point_display
  1828.   Gosub line_display
  1829.  
  1830.  
  1831.   If RawStatus($14)
  1832.     drivfor+1
  1833.   EndIf
  1834.   If RawStatus($15)
  1835.     drivfor-1
  1836.   EndIf
  1837.   drivfor=QLimit(drivfor,-50,50)
  1838.  
  1839.   If RawStatus($22)
  1840.     extra_display_info=NOT extra_display_info
  1841.   EndIf
  1842.   vx=cached_for_view_vx
  1843.   vy=cached_for_view_vy
  1844.   vz=cached_for_view_vz
  1845.  
  1846.   If RawStatus($10)
  1847.     rep_point=999:crep_point=0
  1848.     nofframes=0
  1849.     onof_frames=0
  1850.     frame_speed=.5
  1851.     old_vux=0
  1852.     old_vuy=0
  1853.     old_vuz=0
  1854.   EndIf
  1855.  
  1856.   If RawStatus($11)
  1857.     rep_point=999:crep_poin=0:control_method=#CPUCTRL1
  1858.     nofframes=0
  1859.     onof_frames=0
  1860.     frame_speed=.5
  1861.     old_vux=0
  1862.     old_vuy=0
  1863.     old_vuz=0
  1864.   EndIf
  1865.  
  1866.   If RawStatus($13)
  1867.     Gosub replay
  1868.     nofframes=0
  1869.     onof_frames=0
  1870.     frame_speed=.5
  1871.     old_vux=0
  1872.     old_vuy=0
  1873.     old_vuz=0
  1874.   EndIf
  1875.  
  1876.   man_gear=0
  1877.   If RawStatus($4c) Then man_gear=1
  1878.   If RawStatus($4d) Then man_gear=-1
  1879.   If RawStatus($40) Then handbrake=True Else handbrake=False
  1880.   If RawStatus($42) Then skid_it=True Else skid_it=False
  1881.   If RawStatus($60) Then clutch_on=True Else clutch_on=False
  1882.   If rep_point=999 Then Gosub race_phantom
  1883. Until RawStatus($45)
  1884. Goto back_to_gui
  1885.  
  1886. Goto finish
  1887.  
  1888.  
  1889.  
  1890.  
  1891.  
  1892.  
  1893. ;    ASR.l #8,d4
  1894. .mod_engine
  1895.  
  1896.   *mysound = Addr Sound(1)
  1897.  
  1898.   engine_point_count.l=QWrap(engine_point_count+1,1,32)
  1899.  
  1900.   dasoundlength.l=*mysound\_length*2-65
  1901.   aversample.b=0
  1902.   prevsample.b=0
  1903.   nextsample.b=0
  1904.   currsample.b=0
  1905.   tempwdata.w=0
  1906.   tempbdata.b=0
  1907.   dengvol=QLimit(engvol-oengvol,-64,64)*8
  1908.   oengvol=engvol
  1909.  
  1910.   filterfrequency=QLimit(800/(QLimit(QAbs(engfreq-40),1,10000)),0,8)
  1911.   filterfrequency=(QLimit((filterfrequency/4)^3,0,8))/4
  1912.  
  1913.  
  1914.   turbosound=engine_point_count AND 255
  1915. ;  If has_turbo=True
  1916.   turbovol=QLimit(128-(QAbs(engfreq-turbo_dsp)),0,128)
  1917. ;  If turbovol>0 Then turbovol=1
  1918. ;  Else
  1919. ;  turbovol=0
  1920.   filterfrequency=2*filterfrequency
  1921.   frequencyw.w=(engfreq-300)/30
  1922. ;  EndIf
  1923.   addrl.l=Bank(#SOUNDCACHE)
  1924.   addrl2.l=Bank(#TURBOCACHE)
  1925.   eng_pnt4.l=0
  1926.   word.w=0
  1927.  
  1928.   ffreql.l=filterfrequency*16384;*131071;*32767
  1929.   word.w=turbosound
  1930.   volword.w=turbovol
  1931.   *mysound=Addr Sound(1)
  1932.  
  1933.  
  1934.   GetReg d4,*mysound\_data
  1935.   GetReg d7,engine_point_count
  1936.   GetReg d6,dasoundlength
  1937.   GetReg d5,addrl
  1938.   GetReg d3,&frequencyw
  1939.   GetReg d2,&volword
  1940.   GetReg d1,addrl2;&turbosounddata(0)
  1941.   GetReg d0,sword
  1942.   MOVE.l d1,a3
  1943.   MOVE.l d3,a0
  1944.   MOVE.w (a0),d3
  1945.   ;ASR.l #8,d3
  1946.   ADD.l d7,d5
  1947.   ADD.l d7,d4
  1948.   ADD.l d7,d1
  1949.   MOVE.l d5,a0      ;need a0
  1950.   MOVE.l d4,a1      ;need a1
  1951.   MOVE.l d1,a3      ;need a3
  1952.  
  1953.   MOVE.l d2,a2
  1954.   MOVE.w (a2),d5    ;need d5
  1955.   MOVE.w #128,d2
  1956.   SUB.w d5,d2       ;need d2(=128-d5)
  1957.                     ;need d6
  1958. ;  ASR.l #8,d5
  1959. ;  MOVE.l d0,d7
  1960. modengine_loop:
  1961. ;    MOVE.b -1(a0),d0  ;prev
  1962.     MOVE.b (a0),d1    ;curr
  1963. ;    MOVE.b 0(a0,d3),d2
  1964. ;    MOVE.b 1(a0),d2   ;next
  1965. ;    EXT.w d0
  1966. ;    EXT.w d2
  1967. ;    EXT.w d1
  1968. ;    ADD.w d0,d2     ;d2=aversample
  1969. ;    ASR.w #1,d2
  1970. ;    SUB.w d2,d1     ;curr-aver
  1971. ;    EXT.l d2
  1972. ;    MULS.w d3,d1    ;4*(curr-aver)*filt
  1973. ;    ASR.l #8,d1     ;(curr-aver)*filt
  1974. ;    ADD.l d2,d1     ;aver+(curr-aver)*filt
  1975.     EXT.w d1
  1976. ;    EXT.w d2
  1977.     EXT.l d1
  1978. ;    EXT.l d2
  1979. ;    ASR.l #1,d2
  1980. ;    ADD.l d2,d1
  1981. ;    MOVE.l d2,d1
  1982. ;turbo sound
  1983.     MOVE.b (a3),d4
  1984.  
  1985.     EXT.w d4
  1986.     MULS.w d5,d4
  1987.  
  1988. ;    ASL.l #7,d1
  1989.     MULS.w d2,d1
  1990.  
  1991.     ADD.l d4,d1
  1992.     ASR.l #7,d1
  1993.  
  1994. ;    MOVE.b d4,d1
  1995. ;    EXT.w d1
  1996. ;    EXT.l d1
  1997.  
  1998.     CMP.l #-128,d1        ;clipping
  1999.     BGT modengine_loop1
  2000.     MOVE.b #-128,d1
  2001.     BRA modengine_loop1
  2002.     CMP.l #127,d1
  2003.     BLT modengine_loop1
  2004.     MOVE.b #127,d1
  2005.  
  2006. modengine_loop1:
  2007. ;    MOVE.b (a3),d1
  2008.     MOVE.b d1,(a1)
  2009.     ADD.l #32,a0
  2010.     ADD.l #32,a1
  2011.     ADD.l #32,a3
  2012. ;    ADDI.l #32,d7
  2013. ;    ANDI.l #16383,d7
  2014.     SUBI.l #32,d6
  2015.  
  2016.     BGT modengine_loop
  2017.  
  2018.     turbosound=(turbosound+32) AND 255
  2019.  
  2020.  
  2021.   Return
  2022.  
  2023.  
  2024. .diff_model
  2025.  
  2026. replay=False
  2027. tr_vx=QLimit(vx/32+640,0,1023)
  2028. tr_vy=QLimit(vy/32+640,0,1023)
  2029. map_slip=slippery(tr_vx,tr_vy)
  2030. dt.f=1/25
  2031.  
  2032. Gosub suspension
  2033. ovx.f=vx/10
  2034. ovy.f=vy/10
  2035. ovz.f=vz/10
  2036. ovax.f=vax
  2037. ovay.f=vay
  2038. ovaz.f=vaz
  2039.  
  2040. ovx+ovux*dt
  2041. ovy+ovuy*dt
  2042. ovz+ovuz*dt
  2043.  
  2044. ovuz+10*dt
  2045.  
  2046. dovz=land1{ovx*10,ovy*10}-ovz*10
  2047.  
  2048. If dovz<0
  2049.   ovuz+dovz
  2050. EndIf
  2051.  
  2052. vx=ovx*10
  2053. vy=ovy*10
  2054. vz=ovz*10
  2055. vax=ovax
  2056. vay=ovay
  2057. vaz=ovaz
  2058.  
  2059. Gosub store_replay
  2060.  
  2061.  
  2062. Return
  2063.  
  2064. .suspension
  2065.  
  2066. Return
  2067.  
  2068.  
  2069. .simple_model
  2070.   d_from_land=land1{vx,vy}*mountain-vz
  2071.   CNIF 1=1
  2072.   replay=False
  2073.  
  2074.   tr_vx=QLimit(vx/32+640,0,1023)
  2075.   tr_vy=QLimit(vy/32+640,0,1023)
  2076.   map_slip=slippery(tr_vx,tr_vy)
  2077.   If gear<>ogear
  2078.     gear_change=1
  2079.   EndIf
  2080.     gear_change=QLimit(gear_change-1,0,6)
  2081.   ogear=gear
  2082.  
  2083.   ruy=vux*svaz+vuy*cvaz+ruz*svax
  2084.   ruyfw=vux*Sin(vaz+turn/64)+vuy*Cos(vaz+turn/64)
  2085.   ruxfw=vux*Cos(vaz+turn/64)-vuy*Sin(vaz+turn/64)
  2086.   rux=(vux*cvaz-vuy*svaz)*cvay+ruz*svay*cvax
  2087.  
  2088.   vay=QWrap(vay,0,p2)
  2089.   vaz=QWrap(vaz,0,p2)
  2090.   vax=QWrap(vax,0,p2)
  2091.   If vay>p2 Then vay-p2
  2092.   If vay<0 Then vay+p2
  2093.  
  2094.  
  2095.   cvaz=Cos(vaz)
  2096.   svaz=Sin(vaz)
  2097.   cvay=Cos(vay)
  2098.   svay=Sin(vay)
  2099.   cvax=Cos(vax)
  2100.   svax=Sin(vax)
  2101.   turn_raw=turn
  2102.   turn=turn*QLimit(ruy/10,-1,1)
  2103.  
  2104. If cvax<>0
  2105.   lands=30*cvax
  2106.   landh=land1{vx-lands*svaz,vy-lands*cvaz}*mountain
  2107.   lpitch=((landh-land1{vx+lands*svaz,vy+lands*cvaz})*mountain)/(2*lands)
  2108. EndIf
  2109.   ;land2x=land2x{vx}*mountain
  2110.   ;land2y=land2y{vy}*mountain
  2111.  
  2112. If cvay<>0
  2113.   lands=10*cvay
  2114.  
  2115.   landh=land1{vx-lands*Sin(vaz+Pi/2),vy-lands*Cos(vaz+Pi/2)}*mountain
  2116.   lyaw=(landh-land1{vx+lands*Sin(vaz+Pi/2),vy+lands*Cos(vaz+Pi/2)}*mountain)/(2*lands)
  2117. EndIf
  2118.  
  2119.  
  2120.   landh=land1{vx+10*svaz,vy+10*cvaz}*mountain
  2121.   slopex=-ATan(lpitch)
  2122. ;  vax+slopex
  2123.  ; cvax=Cos(vax)
  2124.  ; svax=Sin(vax)
  2125.  
  2126. ;  lpitch=-land2x*svaz+land2y*cvaz
  2127.   ;lyaw=land2x*cvaz+land2y*svaz
  2128.  
  2129.   If vuy<>0 Then ovux=vux
  2130.   If vuy<>0 Then ovuy=vuy
  2131.  
  2132. ;----------------------------
  2133. ;  Tyre and Engine Sound Fx
  2134. ;----------------------------
  2135.   tyrfreq=120-QAbs(ruy)
  2136.   mod_tyr_freq=Sin(tim_tyr_freq)*200+600
  2137.   tim_tyr_freq=QWrap(tim_tyr_freq+.01,0,p2)
  2138.   tyrfreq=QLimit((((Abs(rux+orux))*100+300)+Rnd(10)+tyrfreq*7)/8,QLimit(200/(10+(ruy/2)),200,300),mod_tyr_freq)
  2139. ;  tyrfreq=120+((QAbs(rux+orux)*10+2000/(10+QAbs(ruy)/2))/2+tyrfreq*15)/16
  2140. ;  tyrfreq=220+QAbs(rux+orux)*10-thrust_skid-QAbs(ruy)
  2141.  
  2142.   tyrvol=QLimit((volorux+(thrust_skid/8)^2+15*(tyrvol))/16,0,64)
  2143.   tyrvol=QLimit((volorux+(ruy-wheel_speed)^2+15*(tyrvol))/16,0,64)
  2144.   If out_of_road=True
  2145.     tyrvol+QAbs(ruy)
  2146.     tyrfreq-QAbs(ruy)*10-thrust_skid*4+200
  2147.   EndIf
  2148.   Freq 1,tyrfreq
  2149.   t_vol=QLimit( (((tyrvol)/25)^4)*QAbs(susp5),0,64)
  2150.   Volume 1,t_vol
  2151.  
  2152.   engvol=(engvol*7+QLimit(QLimit(-CalY2,1,5)*13,16,64))/8
  2153.   Volume 2,QLimit(engvol,1,64)
  2154.   fake_gear_ratio=(fake_gear_ratio+gear_ratio)/2
  2155.  
  2156.   engfreq2=QLimit(20000/(QLimit(2*unreal_speed*fake_gear_ratio,0,200)+1),120,1400)
  2157.  
  2158.   If clutch_on=True
  2159.     engfreq2=1400/(QLimit(-CalY,2,10))
  2160.     clutch_count=32
  2161.   Else
  2162.     clutch_count=QLimit(clutch_count-1,3,32)
  2163.   EndIf
  2164.   If clutch_on=True
  2165.     engfreq=(engfreq*3+engfreq2)/(4)
  2166.     internal_speed=(20000/engfreq-1)/(2*fake_gear_ratio+.01)
  2167.   Else
  2168.     internal_speed=(20000/engfreq-1)/(2*fake_gear_ratio+.01)
  2169.     If clutch_count>10
  2170.       diff_wi_speed=wheel_speed-internal_speed
  2171.       wheel_speed-diff_wi_speed*.5;(32-clutch_count)/32
  2172.       ;internal_speed-diff_wi_speed*.1;(32-clutch_count)/32
  2173.     EndIf
  2174.  
  2175.     engfreq=(engfreq*clutch_count+engfreq2)/(clutch_count+1)
  2176.   EndIf
  2177.  
  2178.  
  2179.   If CalY<0
  2180.     mom_thrust2+CalY*4
  2181.   EndIf
  2182.   mom_thrust2=QLimit(mom_thrust2+2,140,1000)
  2183.  
  2184.   If susp5<>0 Then mom_thrust=engfreq
  2185.   mom_thrust=(mom_thrust2-engfreq)*(1-QLimit(QAbs(susp5),0,1))
  2186.   engfreq3=engfreq+mom_thrust
  2187.   engfreq=(7*engfreq+engfreq3)/8
  2188.   If engine_dsp=True Then Gosub mod_engine
  2189.   Freq 2,engfreq
  2190.  
  2191.   fturbo_boost=1120/turbo_boost
  2192.   fengfreq=1120/engfreq
  2193.   ;If fengfreq>fturbo_boost Then turbo_min=1 Else turbo_min=.5
  2194.  
  2195.   If engfreq<141
  2196.     turbo_max-((141-engfreq)ASR1)
  2197.     turbo_min=.25
  2198.  
  2199.   Else
  2200.     turbo_max=1
  2201.   EndIf
  2202.  
  2203.   xtra_boost=QLimit(turbo_max-QAbs((fturbo_boost-fengfreq)*troll_off),turbo_min,1)
  2204.  
  2205. ;  If has_turbo=True
  2206. ;    If engfreq<170
  2207. ;      xtra_boost=(xtra_boost+2)/2
  2208. ;    Else
  2209. ;      xtra_boost=(xtra_boost+.75)/2
  2210. ;    EndIf
  2211. ;  EndIf
  2212.  
  2213. ;------------------------------
  2214. ; Y A W   S U S P E N S I O N
  2215. ;------------------------------
  2216.  
  2217. susp5l2=QLimit(Abs(susp5),0,2)
  2218. susp5l1=QLimit(susp5l2,0,1)
  2219. tmply=-ATan(lyaw)
  2220.   If vz>landh-20
  2221.     forceonx2=(forceonx2+Force_on_X)/2
  2222.  
  2223.  
  2224.  
  2225.     susp3=(susp3-forceonx2/8)/2
  2226. ;    susp3=(susp3+(-10*forceonx2)/128)/2
  2227.     susp3-susp5l2*Cos(vay)*Sin(vay+tmply)*.1*(downforce)*susp_strength
  2228.   EndIf
  2229.   susp4=(susp4+susp3);-ATan(lyaw/100)/8
  2230.   vay=QWrap(susp4,0,p2);-ATan(lyaw/100)
  2231.   svay2=Sin(-tmply)
  2232.   cvay2=Cos(-tmply)
  2233.  
  2234.  
  2235. ;---------------------------
  2236. ; SPEED SENSITIVE STEERING
  2237. ;---------------------------
  2238.  
  2239.   If S_STEERING=True
  2240.     speed_steering=QLimit(1-ruy*ss_sensitivity/80,.5,1)
  2241.   Else
  2242.     speed_steering=1
  2243.   EndIf
  2244.  
  2245.  
  2246. ;---------------------------------
  2247. ; P I T C H   S U S P E N S I O N
  2248. ;---------------------------------
  2249.  
  2250. ;  slopex=(slopex*15+dlandh*Sgn(ruy)*8)/16
  2251. ;  slopex=(slopex*7+susp5*Sgn(ruy))/8
  2252.   Force_on_Z2l=QLimit(Force_on_Z,-1,1)
  2253.   slopex=ATan(lpitch);QLimit(lpitch,-1,1)
  2254.   susp1=susp5l1*(susp1*7+(ruy-oruy)/128)/8
  2255.  
  2256.   susp2-susp5l1*Cos(-vax)*Sin(vax-slopex)*.1*(1-Force_on_Z2l)*susp_strength
  2257.   susp2=susp2+susp1
  2258.   vax=susp2*4;+slopex
  2259. ;  svax=Sin(vax)
  2260. ;  cvax=Cos(vax)
  2261.  
  2262.   svax2=Sin(slopex)
  2263.   cvax2=Cos(slopex)
  2264.   wheel_load=QLimit(QLimit(susp1+.0125,0,.025)/.025,.01,.99)
  2265.  
  2266.  
  2267. ;-----------
  2268. ; G E A R S
  2269. ;-----------
  2270.  
  2271.   ruyg=ruy*ruyscale
  2272.   If auto_gears=True
  2273.     If susp5<>0
  2274.       If engfreq*rev_limiter<=142
  2275.         If gear<6 Then autochangegear+1
  2276.       Else
  2277.         If engfreq*rev_limiter>200
  2278.           If gear>1 Then autochangegear-1
  2279.         Else
  2280.           autochangegear=0
  2281.         EndIf
  2282.       EndIf
  2283.     EndIf
  2284.     If autochangegear>3 Then gear+1:autochangegear=-6
  2285.     If autochangegear<-6 Then gear-1:autochangegear=0
  2286.   Else
  2287.     If autochangegear>=0
  2288.       autochangegear-1
  2289.     EndIf
  2290.     If man_gear<>0 AND autochangegear<0
  2291.       gear+man_gear
  2292.       autochangegear=5
  2293.     EndIf
  2294.   EndIf
  2295.  
  2296.   gear=QLimit(gear,1,6)
  2297.  
  2298. ;  If ruyg<6 Then gear=1
  2299. ;  If ruyg>12 AND ruyg<13 Then gear=2
  2300. ;  If ruyg>22 AND ruyg <23 Then gear=3
  2301. ;  If ruyg>32 AND ruyg<33 Then gear=4
  2302. ;  If ruyg>41 AND ruyg<42 Then gear=5
  2303. ;  If ruyg>45 Then gear=6
  2304.  
  2305.  
  2306.  
  2307.   gear_ratio=gear_ratio1(gear)
  2308.  
  2309.  
  2310.  
  2311. ;---------------------
  2312. ;WHEEL LOADS AND SPINS
  2313. ;----------------------
  2314.  
  2315. ;  If CalY2<0 AND CalY2>-1 AND ruy<2 Then CalY2=-1
  2316.   If 1=1;vz>=landh-20 AND upside_down=False
  2317.     If fw_drive=True Then thrust_grip=1-wheel_load
  2318.     If rw_drive=True Then thrust_grip=wheel_load
  2319.     If FR_drive=True Then thrust_grip=(1-wheel_load)*power_ratio+wheel_load*(1-power_ratio)
  2320.  
  2321.     skid_on_thrust=(100/(100+.1*(ruy-wheel_speed)^2))
  2322.     skid_on_thrust=QLimit(skid_on_thrust,QAbs(ruy-wheel_speed)*.02,1)
  2323.  
  2324.     If easy_drive=False
  2325.       thrust_grip*skid_on_thrust
  2326.     Else
  2327.       thrust_grip=1
  2328.     EndIf
  2329.  
  2330. ;    avail_HP=xtra_boost*(HPower/6)*QLimit(QAbs((10+unreal_speed)*gear_ratio)/8,.1,100)/(4+QAbs(ruy)/32)
  2331.     avail_HP=xtra_boost*(HPower/4)*gear_ratio
  2332.     If clutch_on=True Then avail_HP=0
  2333.  
  2334.     If gear=0 Then avail_HP=0
  2335.     raw_thrust=QLimit((1-Force_on_Z),0,1)*QLimit(-CalY2,0,10)*avail_HP/16
  2336.     blood_thrust=QLimit(-CalY2,0,10);*avail_HP/16
  2337.  
  2338.     If engfreq*rev_limiter<131
  2339.       raw_thrust=QLimit((engfreq*rev_limiter-130)*.1,-1,1)
  2340.     EndIf
  2341.  
  2342.     If handbrake=True
  2343.       raw_thrust=QLimit(-wheel_speed/4,-1,1)
  2344.     EndIf
  2345.  
  2346. ;THROTTLE HELP
  2347. ;=============
  2348.  
  2349.     If throttle_help=True
  2350.       If thrust_extra>0
  2351.         CalY=CalY/(1+thrust_extra)
  2352.       EndIf
  2353.       If wheel_speed-ruy>1
  2354.         CalY=CalY/(wheel_speed-ruy)
  2355.       EndIf
  2356.     EndIf
  2357.  
  2358.  
  2359. ;WHEEL SPEED
  2360. ;===========
  2361.  
  2362.  
  2363.     raw_thrust/(1+gear_change)
  2364.     thrust=raw_thrust*thrust_grip
  2365.     real_thrust=raw_thrust-Sgn(ruy)*(ruy/10)^2*wing_strength*drag_factor/20
  2366.     thrust_extra=8*(real_thrust-thrust)
  2367.     thrust_skid=QLimit(16*thrust_extra,0,64)
  2368. ;    wheel_speed=QLimit(wheel_speed+thrust_extra*gear_ratio/8,0,100/gear_ratio)
  2369.  
  2370.     anti_spin=1-1/(1+QAbs(susp5l1*road_friction))
  2371.     anti_spin=QLimit(thrust_grip*road_friction*QAbs(susp5l1),0,1)
  2372. ;    tempq.q=(1-QLimit(QAbs(susp5),0,1))*(blood_thrust-1)
  2373.     thrust=(wheel_speed-ruy)*thrust_grip
  2374.     thrustf=(wheel_speed-ruyfw);*thrust_grip
  2375.     thrustfs=(wheel_speed*Sin(turn/64)-rux)*thrust_grip
  2376.  
  2377.  
  2378.  
  2379.     raw_thrust_effect=(raw_thrust-gear_ratio*wheel_speed/200)
  2380.     wheel_speed+(raw_thrust_effect*(1-anti_spin)+(ruy-wheel_speed)*anti_spin)
  2381.     unreal_speed=wheel_speed
  2382.  
  2383.  
  2384.   EndIf
  2385.  
  2386.  
  2387.  
  2388. ;BRAKES
  2389. ;======
  2390.  
  2391.   If CalY2>0 Then stopfactor=CalY Else stopfactor=0
  2392.   brake_temperature+wheel_speed*.01*stopfactor
  2393.   brake_temperature+.1*(32-brake_temperature)*(QAbs(ruy)/1024)
  2394.   brake_effectiveness=10/(10+.0001*(brake_temperature-40)^2)
  2395.   If stopfactor>0 Then fluid_temperature+.002*(brake_temperature-fluid_temperature)
  2396.   fluid_temperature+.001*(32-fluid_temperature)*(1+QAbs(ruy)/1024)
  2397.   fluid_effectiveness=10/(10+.001*(fluid_temperature-50)^2)
  2398.   stopfactor*brake_effectiveness*fluid_effectiveness
  2399.  
  2400.   If stopfactor<>0 AND boomcount<=0
  2401.     If out_of_road=True
  2402.       Sound 9,4,QLimit(QAbs(rux)*4,0,64)
  2403.     Else
  2404.       Sound 8,4,QLimit(QAbs(rux)*4,0,64)
  2405.     EndIf
  2406.     Freq 4,120+Rnd(200)
  2407.     boomcount=5+Int(Rnd(5))
  2408.   EndIf
  2409.  
  2410.   wheel_speed=Sgn(wheel_speed)*QLimit(QAbs(wheel_speed)-stopfactor*.5,0,QAbs(wheel_speed))
  2411.  
  2412.   If stopfactor>0
  2413.     power_ratio=0
  2414.     thrustf=0
  2415.   Else
  2416.     power_ratio=power_ratio2
  2417.   EndIf
  2418.  
  2419.  
  2420. ;GRIP AND TURNING CALCULATIONS
  2421. ;==============================
  2422.  
  2423.  
  2424.   If vz>=landh-20 AND upside_down=False
  2425.     rear_grip=1:front_grip=1
  2426.     If FR_drive=True
  2427.       rear_grip=1-QLimit((1-power_ratio)*(real_thrust-thrust)/turn_factor,0,1)
  2428.       front_grip=1-QLimit((power_ratio)*(real_thrust-thrust)/turn_factor,0,1)
  2429.       rear_grip*skid_on_thrust
  2430.       front_grip*skid_on_thrust
  2431.     Else
  2432.       If rw_drive=True
  2433.         rear_grip=1-QLimit((real_thrust-thrust)/turn_factor,0,1)
  2434.         rear_grip*skid_on_thrust
  2435.       Else
  2436.         If fw_drive=True
  2437.           front_grip=1-QLimit((real_thrust-thrust)/turn_factor,0,1)
  2438.           front_grip*skid_on_thrust
  2439.         EndIf
  2440.       EndIf
  2441.     EndIf
  2442.     rear_grip*(wheel_load)*weight_rear*(1+rear_wing)
  2443.     If handbrake=True Then rear_grip*.5
  2444.     front_grip*(1-wheel_load)*weight_front*(1+front_wing)
  2445.     fwdriveturnthing=100*power_ratio*thrustf
  2446.     showthis1=rux
  2447.     showthis2=10*power_ratio*thrustf
  2448.     showthis3=showthis1+showthis2
  2449. ;    compensate=(Sin(turn/64)*(rux+10*power_ratio*thrustf))*.02
  2450.     compensate=Sin(turn/64)*(rux+power_ratio*wheel_speed)*.02
  2451. ;    compensate+
  2452.     ;vwz+power_ratio*thrust*Sin(turn/64)
  2453.     turn_factor*car_turn_factor
  2454.     compensate+front_grip*Sin(turn/64)
  2455.     vwz+(speed_steering*turn_factor)*(compensate-vwz*(rear_grip+front_grip)/2)/(2+QAbs(rux))
  2456.   EndIf
  2457.   vaz+vwz
  2458.  
  2459.  
  2460.  
  2461.   cvaz=Cos(vaz)
  2462.   svaz=Sin(vaz)
  2463.   cvay=Cos(vay)
  2464.   svay=Sin(vay)
  2465.   cvax=Cos(vax)
  2466.   svax=Sin(vax)
  2467.  
  2468.  
  2469.   ruy=vux*svaz+vuy*cvaz+vuz*svax
  2470.   rux=(vux*cvaz-vuy*svaz)*cvay+vuz*svay*cvax
  2471.  
  2472.   oruy=ruy
  2473.  
  2474. ;--------------------------
  2475. ;       DOWNFORCE
  2476. ;--------------------------
  2477.  
  2478.   ;gravity=1.5
  2479.   downforce=gravity+Sgn(ruy)*(ruy/10)^2*wing_strength/10
  2480.  
  2481.  
  2482.  
  2483.   dorux=rux-orux
  2484.   orux=rux
  2485.   ;orux=QLimit(rux,-3,3)
  2486.   volorux=8*QAbs(rux)
  2487.  
  2488. snd_xtra=-1
  2489. vay=QWrap(vay,0,p2)
  2490.  
  2491.  
  2492.   pd1=QLimit(cd_closest_point-12,1,points1)
  2493.   pd2=QLimit(cd_closest_point+12,1,points1)
  2494.   pdxmin=ox(pd1)
  2495.   pdymin=oy(pd1)
  2496.   pdxmax=ox(pd1)
  2497.   pdymax=oy(pd2)
  2498.   For i=pd1 To pd2
  2499.     pdxmin=Min(pdxmin,ox(i))
  2500.     pdymin=Min(pdymin,oy(i))
  2501.     pdxmax=Max(pdxmax,ox(i))
  2502.     pdymax=Max(pdymax,oy(i))
  2503.   Next i
  2504.  
  2505.    If pdxmin>0 OR pdymin>0 OR pdxmax<0 OR pdymax<0
  2506.      slip_factor=1
  2507.    Else
  2508.      slip_factor=0
  2509.    EndIf
  2510.   skid_factor=(skid_factor+slip_factor)/2
  2511. If vz>landh-20
  2512.     If QAbs(vay-Pi)>Pi/2 AND (vax<Pi/2 OR vax>3*Pi/2)
  2513.         If skid_factor>.5
  2514.             If out_of_road=False
  2515.               LoopSound 2,1,tyrvol:Freq 1,tyrfreq
  2516.               t_snd=2
  2517.             EndIf
  2518.             out_of_road=True
  2519.         Else
  2520.             If out_of_road=True
  2521.               LoopSound 0,1,tyrvol:Freq 1,tyrfreq
  2522.               t_snd=0
  2523.             EndIf
  2524.             out_of_road=False
  2525.         EndIf
  2526.         If upside_down=True
  2527.           LoopSound 0,1,tyrvol
  2528.         EndIf
  2529.         upside_down=False
  2530.     Else
  2531.         If upside_down=False
  2532.           LoopSound 3,1,64:Freq 1,tyrfreq
  2533.           t_snd=3:t_vol=64
  2534.           Sound 6,4,64:boomcount=11
  2535.           snd_xtra=6
  2536.         EndIf
  2537.         upside_down=True
  2538.     EndIf
  2539. Else
  2540.   Volume 1,0
  2541. EndIf
  2542.  
  2543.  
  2544.   pressure=tyre_pressure/3
  2545.   If skid_factor>.5
  2546.     road_friction=field_advantage*track_grip/(1+skid_factor*2)
  2547.   Else
  2548.     road_friction=track_grip
  2549.   EndIf
  2550.  
  2551.   Force_on_Z=0
  2552.  
  2553.   hitbump=0
  2554.   mud_dig2=(mud_dig2*15+mud_dig)/16
  2555.   mud_dig=1
  2556.   If bumps=True AND vz>landh-17 AND skid_factor>.5
  2557.     If Rnd<.1 Then hitside=(susp_strength*skid_factor*rux*(Rnd-.5))/4 Else hitside=0
  2558.     hitside=1+hitside/field_advantage
  2559.     mud_dig=(1-downforce*0.05/(field_advantage^2))
  2560.     downforce=downforce*hitside
  2561.     vux*mud_dig2:vuy*mud_dig2
  2562.  
  2563.  
  2564.     M_on_Z=0
  2565.     If Rnd<.1
  2566.       hitside2=(susp_strength*skid_factor*ruy*(Rnd-.5))/10
  2567.       Force_on_Z=QLimit(-5*QAbs(hitside2),-10,0)/field_advantage
  2568.       downforce=0
  2569.       M_on_Z=(Rnd-.5)*.1*QAbs(ruy)
  2570.       vuz-susp_strength*Rnd*Abs(ruy)/24
  2571.       susp1+hitside2/10000
  2572.       hitside+ruy*(Rnd-.5)
  2573.       If boomcount=0 Then Sound 5,4,QAbs(ruy)
  2574.  
  2575.       vux*.99:vuy*.99
  2576.  
  2577.    EndIf
  2578.   Else
  2579.     hitside=1
  2580.   EndIf
  2581.  
  2582.  
  2583. ;---------------------
  2584. ;     ADD THRUST
  2585. ;---------------------
  2586.  
  2587. ;RW Thrust always in direction of vehicle
  2588. ;========================================
  2589.   add_vux=(1-power_ratio)*thrust*svaz*cvax
  2590.   add_vuy=(1-power_ratio)*thrust*cvaz*cvax
  2591.  
  2592. ;Use Vehicle+Wheel Angle for FW Thrust
  2593. ;=====================================
  2594.  
  2595.   add_vux+power_ratio*thrustf*Sin(vaz+turn/64)*cvax
  2596.   add_vuy+power_ratio*thrustf*Cos(vaz+turn/64)*cvax
  2597.  
  2598.   Force_on_Z=QLimit(Force_on_Z,-20,10)
  2599.  
  2600.  
  2601.   Force_on_X=(hitside-1)*bump_height/field_advantage+QLimit(dorux,-pressure*downforce,pressure*downforce)/4
  2602.   If vz<landh-17 Then Force_on_Z=0
  2603.  
  2604.  
  2605.  
  2606.   ;=========================
  2607.   ;      VZ SUSPENSION
  2608.   ;=========================
  2609.  
  2610. ;
  2611.   If vz>landh+10
  2612.     ;dvlandz=10*(10+QAbs(landh+10-vz))
  2613.     ;vux*dvlandz
  2614.     ;vuy*dvlandz
  2615.     ;vuz*dvlandz
  2616.     ;vuz+(landh+10-vz)/2
  2617.     ;vz=landh+10
  2618.  
  2619.     land_p1x=vx+10*cvaz
  2620.     land_p1y=vy+10*cvaz
  2621.  
  2622.     land_p2x=land_p1x-2*vux*frame_speed
  2623.     land_p2y=land_p1y-2*vuy*frame_speed
  2624.  
  2625.     land_len=Sqr((land_p2x-land_p1x)^2+(land_p2y-land_p1y)^2)
  2626.  
  2627.     landh_p=land1{land_p2x,land_p2y}*mountain
  2628.  
  2629. ;    dvlandz=QLimit(landh+10-vz,-10,10)
  2630. ;    vz+1;dvlandz
  2631.     vuz=0
  2632.  
  2633. ;    land_vz=vz-landh_p
  2634.     landh_p1=landh-landh_p
  2635.  
  2636.     If landh_p1<>0
  2637.       part_len=(vz-landh_p)*land_len/landh_p1
  2638.     Else
  2639.       part_len=0
  2640.     EndIf
  2641.  
  2642.     If land_len<>0
  2643.       vx_col=land_p2x;-(land_p1x-land_p2x)*part_len/land_len
  2644.       vy_col=land_p2y;-(land_p1y-land_p2y)*part_len/land_len
  2645.       vux=0;-(vx-vx_col)*.5
  2646.       vuy=0;-(vy-vy_col)*.5
  2647.       vx=vx_col
  2648.       vy=vy_col
  2649.       landh=land1{vx+10*cvaz,vy+10*cvaz}*mountain
  2650.     EndIf
  2651.   Else
  2652.     susp5=0
  2653.  
  2654.   EndIf
  2655.   ;If QAbs(vuz)<=.1 Then vuz=0
  2656.   osusp5=susp5
  2657.   dxsusp5=(dxsusp-odxsusp)*4*susp_strength
  2658.   odxsusp=dxsusp
  2659.   dxsusp=((vz+#SUSP_HEIGHT)-landh)
  2660.  
  2661.   If dxsusp>=0
  2662.     susp5=-dxsusp
  2663.   Else
  2664.     susp5=0
  2665.   EndIf
  2666.   testsusp5=susp5
  2667.  
  2668.   If dxsusp5>0 AND vz>=landh-#SUSP_HEIGHT Then susp5-dxsusp5
  2669.   ;If vz>=landh-16 Then susp5+(susp5-osusp5)
  2670.   boomcount=QLimit(boomcount-1,0,10)
  2671.   If boomcount=0 AND susp5<=-8
  2672.     If susp5<=-12
  2673.       Sound 6,4,64:boomcount=5+Rnd(5)
  2674.     Else
  2675.       Sound 3,4,64:boomcount=Rnd(5)
  2676.     EndIf
  2677.   EndIf
  2678.   If (Rnd*8+4)<-susp5
  2679.     tempw=Rnd(64)
  2680.     Sound 5,4,tempw
  2681.   EndIf
  2682.  
  2683.   susp5=susp5/(2*frame_speed)
  2684.   If susp5<-12 Then vuz=-QAbs(vuz)*12/susp5
  2685. ;  susp5=QLimit(susp5,-4,0)
  2686. ;  If vz>=landh-8 AND vz<=landh
  2687. ;    susp5+(landh-8-vz)
  2688. ;  EndIf
  2689.  
  2690.   If vz>=landh-#SUSP_HEIGHT Then Force_on_Z+(susp5);*(1+cvax)
  2691.  
  2692.  
  2693.  
  2694.   downforce2=QLimit(-Force_on_Z,-20,20);+downforce
  2695.   Force_on_Z_2=testsusp5
  2696.   Force_on_Z+downforce
  2697.   downforce=QLimit(-testsusp5,-4,4)
  2698.   Force_on_Z_v=Force_on_Z
  2699.   If  QAbs(vay-Pi)>Pi/2 AND vz>=landh-20
  2700.  
  2701.     lyaw2=Sqr(QAbs(1-lyaw^2))
  2702.     Force_on_Z_v=Force_on_Z*lyaw2
  2703.     Force_on_Z_h=Force_on_Z_2*lyaw
  2704.  
  2705.     max_force=pressure*downforce
  2706.  
  2707.     add_vux-QLimit(rux*cvaz,-max_force,max_force)
  2708.     add_vuy+QLimit(rux*svaz,-max_force,max_force)
  2709.     add_vux-QLimit(QLimit(Sgn(vux)*QLimit(stopfactor,0,QAbs(vux)),-max_force,max_force),-pressure/2,pressure/2)
  2710.     add_vuy-QLimit(QLimit(Sgn(vuy)*QLimit(stopfactor,0,QAbs(vuy)),-max_force,max_force),-pressure/2,pressure/2)
  2711.  
  2712.     add_v=Sqr(add_vux^2+add_vuy^2)
  2713.     skid_loss=1/skidding
  2714.  
  2715.     turn_factor=road_friction*downforce;*QAbs(susp5)
  2716.     If turn_factor<=0 Then turn_factor=.01
  2717.     If add_v<>0
  2718.       add_sin=add_vux/add_v
  2719.       add_cos=add_vuy/add_v
  2720.       abssusp5=QAbs(susp5)
  2721.       dsusp5=abssusp5*road_friction*downforce
  2722.       ssusp5=svax*abssusp5
  2723.       abs_sin=QAbs(add_sin)*dsusp5*skidloss
  2724.       abs_cos=QAbs(add_cos)*dsusp5*skidloss
  2725.       If add_v>dsusp5
  2726.         addskid=.05*(add_v/dsusp5-1)
  2727.         skidding=QLimit(skidding+addskid,1,10)
  2728.       Else
  2729.         skidding=QLimit(skidding-.5,1,10)
  2730.       EndIf
  2731.       If skidding<1.5
  2732.         skidloss=1/skidding
  2733.       Else
  2734.         skidloss=.1*(skidding-1.5)+1/1.5
  2735.       EndIf
  2736.       skidloss=(1+skidloss)/2
  2737.       If easy_drive=True Then skidloss=1
  2738.  
  2739.       If skid_it=False
  2740.       vux+(QLimit(add_vux,-abs_sin,abs_sin)-svaz*ssusp5);*.75
  2741.       vuy+(QLimit(add_vuy,-abs_cos,abs_cos)-cvaz*ssusp5);*.75
  2742.  
  2743.       add_vuz1=QLimit(add_vux,-abs_sin,abs_sin)
  2744.       add_vuz2=QLimit(add_vuy,-abs_cos,abs_cos)
  2745.  
  2746.       add_vuzx=-add_vuz2*Sin(vaz)+add_vuz1*Cos(vaz)
  2747.       add_vuzy=add_vuz2*Cos(vaz)+add_vuz1*Sin(vaz)
  2748.  
  2749.  
  2750.       add_vuz1=(add_vuzx*svay2)
  2751.       add_vuz2=(add_vuzy*svax2)
  2752.       add_vuz=add_vuz1+add_vuz2
  2753.       vuz-add_vuz
  2754.  
  2755.       EndIf
  2756. ;      vux+(tmply*Sin(vaz+Pi/2)*abssusp5)*.75
  2757. ;      vuy+(tmply*Cos(vaz+Pi/2)*abssusp5)*.75
  2758.  
  2759.       landxsin=(land1{vx+10,vy}-land1{vx-10,vy})/20
  2760.       landysin=(land1{vx,vy+10}-land1{vx,vy-10})/20
  2761.       vux-landxsin*Force_on_Z_2;/4
  2762.       vuy-landysin*Force_on_Z_2;/4
  2763.  
  2764.     EndIf
  2765.   EndIf
  2766.  
  2767.   total_drag=wing_strength*drag_factor/20
  2768.   vux=vux-(Sgn(vux)*(vux/10)^2*total_drag)*.75
  2769.   vuy=vuy-(Sgn(vuy)*(vuy/10)^2*total_drag)*.75
  2770.  
  2771.    vuz+QLimit(Force_on_Z_v,-20,10)/4
  2772.  
  2773.  
  2774.  
  2775.  
  2776. ;  dold_vax=vax-old_vax
  2777. ;  dold_vay=vay-old_vay
  2778. ;  dold_vaz=vaz-old_vuz
  2779.  
  2780. ;  dold_vaz=vaz-old_vuz
  2781. ;  dold_va
  2782.  
  2783.   If frame_rate_correction=True
  2784.     dold_vux=vux-old_vux
  2785.     dold_vuy=vuy-old_vuy
  2786.     dold_vuz=vuz-old_vuz
  2787.  
  2788.     vux1=old_vux+dold_vux*frame_speed
  2789.     vuy1=old_vuy+dold_vuy*frame_speed
  2790.     vuz1=old_vuz+dold_vuz*frame_speed
  2791.  
  2792.     old_vux=vux
  2793.     old_vuy=vuy
  2794.     old_vuz=vuz
  2795.     vux=vux1
  2796.     vuy=vuy1
  2797.     vuz=vuz1
  2798.   EndIf
  2799.  
  2800.  
  2801.  
  2802.   vz+vuz*frame_speed
  2803.   vx+vux*frame_speed
  2804.   vy+vuy*frame_speed
  2805.  
  2806.   If QAbs(vx)>20001 OR tr_vx=0 OR tr_vx=1023 Then vx-frame_speed*vux:vux=-.5*vux
  2807.   If QAbs(vy)>20001 OR tr_vy=0 OR tr_vy=1023 Then vy-frame_speed*vuy:vuy=-.5*vuy
  2808.   vx=QLimit(vx,-20000,20000)
  2809.   vy=QLimit(vy,-20000,20000)
  2810.  
  2811.   Gosub store_replay
  2812.  
  2813. CEND
  2814. Return
  2815.  
  2816.  
  2817.  
  2818.  
  2819. .store_replay
  2820.   replay(rep_point)\x=vx
  2821.   replay(rep_point)\y=vy
  2822.   replay(rep_point)\z=vz
  2823.   replay(rep_point)\ax=vax
  2824.   replay(rep_point)\ay=vay
  2825.   replay(rep_point)\az=vaz
  2826.   replay(rep_point)\e_freq=engfreq
  2827.   replay(rep_point)\e_vol=engvol
  2828.   replay(rep_point)\t_freq=tyrfreq
  2829.   replay(rep_point)\t_vol=t_vol
  2830.   replay(rep_point)\t_snd=t_snd
  2831.  
  2832.   If control_method<>#CPUCTRL1
  2833.     cpurep(rep_point)\x=vx
  2834.     cpurep(rep_point)\y=vy
  2835.     cpurep(rep_point)\z=vz
  2836.     cpurep(rep_point)\ax=vax
  2837.     cpurep(rep_point)\ay=vay
  2838.     cpurep(rep_point)\az=vaz
  2839.     cpurep(rep_point)\e_freq=engfreq
  2840.   EndIf
  2841.  
  2842.  
  2843.   rep_point=QWrap(rep_point+1,0,1000)
  2844.   If racing=True
  2845.     vec_obj(0)\x=replay(rep_point)\x
  2846.     vec_obj(0)\y=replay(rep_point)\y
  2847.     vec_obj(0)\z=replay(rep_point)\z
  2848.     vec_obj(0)\ax=replay(rep_point)\ax
  2849.     vec_obj(0)\ay=replay(rep_point)\ay
  2850.     vec_obj(0)\az=replay(rep_point)\az
  2851.  
  2852.     old_rel_d=rel_d
  2853.     rel_x=(replay(rep_point)\x-vx)
  2854.     rel_y=(replay(rep_point)\y-vy)
  2855.     rel_z=(replay(rep_point)\z-vz)
  2856.     rel_d=Sqr(rel_x^2+rel_y^2+rel_z^2)
  2857.     rel_u=(rel_d-old_rel_d)*Kdoppler
  2858.  
  2859.   If control_method=#CPUCTRL1
  2860.     crep_point=QLimit(crep_point+1,0,1000)
  2861. crep:
  2862.     cold_rel_d=crel_d
  2863.     cpu_lahead=Abs(ruy)/10
  2864.     crep_low=QLimit(crep_point-10-cpu_lahead,0,999)
  2865.     crep_hi=QLimit(crep_point+10+cpu_lahead,0,999)
  2866.     crep_min=-1
  2867.     For crepsort.w=crep_low To crep_hi
  2868.       crel_x=(cpurep(crepsort)\x-vx)
  2869.       crel_y=(cpurep(crepsort)\y-vy)
  2870.       crel_z=(cpurep(crepsort)\z-vz)
  2871.       crel_d=Sqr(crel_x^2+crel_y^2+crel_z^2)
  2872.       If crep_min=-1
  2873.         crep_min=crel_d
  2874.         crep_point=crepsort
  2875.       Else
  2876.         If crel_d<crep_min
  2877.           crep_point=crepsort
  2878.           cold_rel_d=crel_d
  2879.           crep_min=crel_d
  2880.         EndIf
  2881.       EndIf
  2882.     Next crepsort
  2883.  
  2884.  
  2885.     crep_point+4+cpu_lahead
  2886.       crel_x=(cpurep(crep_point)\x-vx)
  2887.       crel_y=(cpurep(crep_point)\y-vy)
  2888.       crel_z=(cpurep(crep_point)\z-vz)
  2889.       crel_d=Sqr(crel_x^2+crel_y^2+crel_z^2)
  2890.       crel_vaz=QWrap((cpurep(crep_point)\az-vaz),-Pi,Pi)
  2891.  
  2892.     crel_dx=(crel_x+vx-cpurep(crep_point-1)\x)
  2893.     crel_dy=(crel_y+vy-cpurep(crep_point-1)\y)
  2894.     crel_dz=(crel_z+vz-cpurep(crep_point-1)\z)
  2895.     crel_uy=Sqr(crel_dx^2+crel_dy^2+crel_dz^2)
  2896.     tmpcrel=1+ruy/4
  2897.     If tmpcrel<>0
  2898.       crel_u=(crel_d-cold_rel_d)/tmpcrel
  2899.     EndIf
  2900.  
  2901.     orel_angle=rel_angle
  2902.     rel_angle=QWrap(p2*QAngle(0,0,crel_y,crel_x)-vaz,-Pi,Pi)
  2903.  
  2904.     ctrl\dx1=ctrl\dx
  2905.     ctrl\dx=rel_angle
  2906.     Gosub controller
  2907.  
  2908.     ctrl_force=ctrl\force
  2909. ;    If ctrl\force<-10 Then ctrl_force=-10
  2910. ;    If ctrl\force>10 Then ctrl_force=10
  2911.   vaz_cpu=QWrap(vaz+cpu_turn/64,0,p2)
  2912.  
  2913.   rux_cpu=vux*Cos(vaz_cpu)-vuy*Sin(vaz_cpu)
  2914.   dif_rux=Abs(rux_cpu)-Abs(1.1*rux)
  2915.   If dif_rux>0
  2916.     ctrl_force-dif_rux*.5*Sgn(cpu_turn)*Abs(ctrl_force)
  2917.   EndIf
  2918.     cpu_turn*.5
  2919.  
  2920.     cpu_turn+ctrl_force
  2921.     vaz_cpu=vaz+cpu_turn
  2922.  
  2923.  
  2924.     ;cpu_accel=(cpu_accel+4*crel_uy-ruy)
  2925.     cpu_accel=(3*cpu_accel+crel_u+2*(2*crel_uy-ruy))/4
  2926.  
  2927.     ;If Abs(cpu_turn)>5 OR crel_d<60 Then crep_point+1
  2928.     ;If crel_d>100 Then crep_point-1
  2929.     ;If crel_d>200 AND Abs(cpu_turn)<5 Then crep_point-1
  2930.     ;If Abs(cpu_turn<5) Then crep_point-1
  2931.  
  2932.     EndIf
  2933.  
  2934.  
  2935.     eng_freq=replay(rep_point)\e_freq
  2936.     eng_freq=QLimit(eng_freq+rel_u,120,8000)
  2937.     eng_vol=QLimit((replay(rep_point)\e_vol)*128/(2+(rel_d)),0,64)
  2938.  
  2939.     Volume 8,eng_vol
  2940.     Freq 8,eng_freq
  2941.   EndIf
  2942.  
  2943.  
  2944.   prevx=bvx
  2945.   prevy=bvy
  2946.   prevz=bvz
  2947.  
  2948.   bvx=vx
  2949.   bvy=vy
  2950.   bvz=vz
  2951.   bvax=vax
  2952.   bvaz=vaz
  2953.   bvay=vay
  2954.  
  2955.  
  2956.  
  2957.  
  2958. .filter_input
  2959.  
  2960.   If ((control_method=#DIJOYCTRL) OR (control_method=#KEYSCTRL))
  2961.     digturn3=QLimit(digturn3+digturn/(2+QAbs(ruy/40)),-10,10)*QAbs(Sgn(digturn))
  2962.  
  2963.  
  2964.     digturn2+digturn3
  2965.     digturn2*.99;*(.1+QAbs(Sgn(digturn)))
  2966.     turn=digturn2
  2967.  
  2968.     If digaccel>0
  2969.       If throttle_help=False
  2970.         CalY=QLimit(CalY-.25,-10,0)
  2971.       Else
  2972.         CalY=(CalY-10)/2
  2973.       EndIf
  2974.     Else
  2975.       If digaccel<0
  2976.         CalY=CalY+10
  2977.       Else
  2978.         CalY=0
  2979.       EndIf
  2980.     EndIf
  2981.  
  2982.  
  2983.   EndIf
  2984.  
  2985.  
  2986.   turn2=(turn2*3+turn)/4
  2987.   If QAbs(turn)<2
  2988.     turn=Sgn(turn)*(turn^2)/2
  2989.   EndIf
  2990.   turn=QLimit(turn,-20,20)
  2991.   turn2=QLimit(turn2,-10,10)
  2992.  
  2993.     CalY2=CalY;(CalY2*3+CalY)/4
  2994.  
  2995.   If QAbs(CalY)<4
  2996.     CalY2=CalY2*Sqr(QAbs(CalY))/2
  2997.   EndIf
  2998.   CalY=QLimit(CalY,-100,100)
  2999.   CalY2=QLimit(CalY2,-10,10)
  3000.  
  3001. Return
  3002.  
  3003. .controller
  3004.  
  3005.   USEPATH ctrl
  3006.  
  3007.  
  3008.   \d2x1=\d2x
  3009.   \d2x=\dx-\dx1      ;d2x == speed
  3010.  
  3011.   \d3x=\d2x-\d2x1    ;d3x == acceleration
  3012.  
  3013.   \force1=\force
  3014.  
  3015.   If \d3x=0
  3016.     \a=.01
  3017.   Else
  3018.     \a=(\force1)/(\d3x)  ;accel==force/mass
  3019.   EndIf
  3020.  
  3021.   \d2x2=-\dx
  3022.  
  3023.   \nd3x=\d2x-\d2x2
  3024.   If \a=0
  3025.     \force=\dx
  3026.   Else
  3027.     \force=\nd3x*Abs(\a)
  3028.  EndIf
  3029.  
  3030.   absdx.f=5*Abs(\dx)
  3031.   If \force>absdx Then \force=absdx
  3032.   If \force<-absdx Then \force=-absdx
  3033.  
  3034. Return
  3035.  
  3036. .replay
  3037.   otr_vx=tr_vx
  3038.   otr_vy=tr_vy
  3039.  
  3040.  
  3041.  
  3042.   replay=True
  3043.   closest_point=1
  3044.   cachex=vx
  3045.   cachey=vy
  3046.   cachez=vz
  3047.   cacheax=vax
  3048.   cacheay=vay
  3049.   cacheaz=vaz
  3050.  
  3051.   rep_timer=0
  3052.   rep_point=0
  3053.   rep_n=0
  3054.   LoopSound 4,1
  3055.   LoopSound 4,4
  3056.   LoopSound 4,8
  3057.   t_snd=-1
  3058.   Repeat
  3059.     rep_pnt=QWrap(rep_point+rep_n,0,1000)
  3060.     vec_obj(0)\x=replay(rep_pnt)\x
  3061.     vec_obj(0)\y=replay(rep_pnt)\y
  3062.     vec_obj(0)\z=replay(rep_pnt)\z
  3063.     vec_obj(0)\ax=replay(rep_pnt)\ax
  3064.     vec_obj(0)\ay=replay(rep_pnt)\ay
  3065.     vec_obj(0)\az=replay(rep_pnt)\az
  3066.  
  3067.     t_freq=replay(rep_pnt)\t_freq
  3068.     t_vol=replay(rep_pnt)\t_vol
  3069.     ot_snd=t_snd
  3070.     t_snd=replay(rep_pnt)\t_snd
  3071.  
  3072.     If t_snd<>ot_snd
  3073.       LoopSound t_snd,8
  3074.     EndIf
  3075.  
  3076.     switch_camera=RectsHit(vx-1000,vy-1000,2000,2000,replay(rep_pnt)\x,replay(rep_pnt)\y,10,10)
  3077.     switch_camera=(NOT switch_camera) AND (moving_camera<>0)
  3078.     switch_camera=(switch_camera) OR (rep_timer<=0)
  3079.     If camera_type>0
  3080.       switch_camera=False
  3081.     Else
  3082.       If moving_camera=0 AND rotating_camera2<.01
  3083.         If left_camera>=5
  3084.           switch_camera=True
  3085.           left_camera=0
  3086.         EndIf
  3087.       EndIf
  3088.     EndIf
  3089.  
  3090.  
  3091.     rotating_camera=(rotating_camera*7+rotating_camera2)/8
  3092.     If (switch_camera)
  3093.       rotating_camera=1
  3094.       rotating_camera2=QLimit(Rnd*2-.5,0,1)
  3095.       cmrdist=(dop_vux/2)^2+(dop_vuy/2)^2
  3096.       vx=replay(rep_pnt)\x+(cmrdist+Rnd(500))*Sin(replay(rep_pnt)\az+(Rnd-.5))
  3097.       vy=replay(rep_pnt)\y+(cmrdist+Rnd(500))*Cos(replay(rep_pnt)\az+(Rnd-.5))
  3098.  
  3099.       rep_timer=200
  3100.       If Rnd>.66
  3101.         moving_camera=Rnd:replay_zoom=1
  3102.         vz=-Rnd*18*Sqr(cmrdist)-5+vec_obj(0)\z
  3103.         rotating_camera2+.1
  3104.       Else
  3105.         moving_camera=0:replay_zoom=0
  3106.         rep_timer=25+Int(Rnd*75)
  3107.         rep_pnt2=QWrap(rep_pnt+rep_timer/2,0,1000)
  3108.         vx=replay(rep_pnt2)\x+Rnd(200)-100
  3109.         vy=replay(rep_pnt2)\y+Rnd(200)-100
  3110.         vz=replay(rep_pnt2)\z+Rnd(100)-50
  3111.         vz=QLimit(vz,-10000,land1{vx,vy}*mountain-8)
  3112. ;        vz=-Rnd*6*Sqr(cmrdist)+50+vec_obj(0)\z
  3113.  
  3114.  
  3115.       EndIf
  3116.       rep_vux=0
  3117.       rep_vuy=0
  3118.       Volume 1|2|4|8,0,0,0,0
  3119.     EndIf
  3120.  
  3121.     dop_vux=(replay(rep_pnt)\x-ovx)
  3122.     dop_vuy=(replay(rep_pnt)\y-ovy)
  3123.     rel_vux=dop_vux*moving_camera
  3124.     rel_vuy=dop_vuy*moving_camera
  3125.     ovx=replay(rep_pnt)\x
  3126.     ovy=replay(rep_pnt)\y
  3127.     rep_vux=QLimit((rep_vux*7+rel_vux)/8,-20,20)
  3128.     rep_vuy=QLimit((rep_vuy*7+rel_vuy)/8,-20,20)
  3129.     vx+rep_vux
  3130.     vy+rep_vuy
  3131.  ;   top_h=Min(replay(rep_pnt)\12,land1{vx,vy}*mountain-16)
  3132.       top_h=land1{vx,vy}*mountain-16
  3133.  
  3134.     If moving_camera>0
  3135.       vz=QLimit(vz+(rel_z-60)/128,-5000,top_h)
  3136.     EndIf
  3137.     old_rel_d=rel_d
  3138.     rel_x=(replay(rep_pnt)\x-vx)
  3139.     rel_y=(replay(rep_pnt)\y-vy)
  3140.     rel_z=(replay(rep_pnt)\z-vz)
  3141.     rel_d=Sqr(rel_x^2+rel_y^2+rel_z^2)
  3142.  
  3143.     If rel_d>500 AND rel_u>0
  3144.       switch_camera+1
  3145.       If switch_camera>=10
  3146.         rep_timer=1
  3147.         switch_camera=0
  3148.       EndIf
  3149.     EndIf
  3150.     rel_u=(rel_d-old_rel_d)*Kdoppler
  3151.     eng_freq=replay(rep_pnt)\e_freq
  3152.     eng_freq=QLimit(eng_freq+rel_u,120,8000)
  3153.     eng_vol=QLimit((replay(rep_pnt)\e_vol*64)/(1+(rel_d)),0,64)
  3154.     eng_vol2=eng_vol*.75;(QLimit(128/(1+(rel_d/10)),0,64))
  3155.     t_vol=QLimit(t_vol*64/(1+(rel_d)),0,64)
  3156.     If t_vol<t_vol2
  3157.       t_vol2=(t_vol+t_vol2)/2
  3158.     Else
  3159.       t_vol2=t_vol
  3160.     EndIf
  3161.     t_freq=QLimit(t_freq+rel_u,120,8000)
  3162.     Freq 2,eng_freq
  3163.     Volume 2,eng_vol
  3164.  
  3165.     echoa=QLimit((echoa+1) MOD 50,0,50)
  3166.     oengfreqa(echoa)=eng_freq
  3167.     oengvola(echoa)=eng_vol
  3168.     echola2=(rel_d ASR 7)
  3169.  
  3170.     dechola2=QLimit((echola2 MOD 50),0,50)
  3171.     dechola2=QLimit((echoa-dechola2)MOD 50,0,50)
  3172.  
  3173.     Freq 1,oengfreqa(QLimit(dechola2 MOD 50,0,50))
  3174.     Volume 1,oengvola(QLimit(dechola2 MOD 50,0,50))*.9
  3175.  
  3176.     Freq 4,oengfreqa(QLimit((dechola2-echola)MOD 50,0,50))
  3177.     Volume 4,oengvola(QLimit((dechola2-echola)MOD 50,0,50))*.75
  3178.  
  3179.     ;Freq 8,oengfreqa(QWrap(echoa-2*echola-echola2,0,50))
  3180.     ;Volume 8,oengvola(QWrap(echoa-2*echola-echola2,0,50))*.5
  3181.     Freq 8,t_freq
  3182.     Volume 8,t_vol2
  3183.  
  3184.  
  3185.      oeng_freq=eng_freq
  3186.     oeng_vol=eng_vol2;QLimit((oeng_vol+eng_vol2)/2,0,64)
  3187.  
  3188.     rep_timer-1
  3189.     vaz_c=Pi/2-Pi*2*QAngle(vx,vy,replay(rep_pnt)\x,replay(rep_pnt)\y)
  3190.     targety=Sqr((replay(rep_pnt)\x-vx)^2+(replay(rep_pnt)\y-vy)^2)
  3191.     vax_c=(-Pi*2*QAngle(0,vz,targety,replay(rep_pnt)\z))
  3192. ;    If rotating_camera2>0
  3193. ;      rotating_camera=1
  3194. ;    Else
  3195. ;      rotating_camera=0
  3196. ;    EndIf
  3197.  
  3198.     If QAbs(vaz_c-vaz)>Pi/2
  3199.       left_camera+1
  3200.     Else
  3201.       left_camera=0
  3202.     EndIf
  3203.  
  3204.     vaz+QWrap(vaz_c-vaz,-Pi,Pi)*rotating_camera
  3205.  
  3206.     vax=vax_c;+QWrap(vax_c-vax,-Pi,Pi)*rotating_camera
  3207.     vay=0
  3208.     Select camera_type
  3209.       Case 1
  3210.         vax=replay(rep_pnt)\ax
  3211.         vay=replay(rep_pnt)\ay
  3212.         vaz=replay(rep_pnt)\az
  3213.         ovx_f=vx_f
  3214.         ovy_f=vy_f
  3215.         ovz_f=vz_f
  3216.         vx_f=replay(rep_pnt)\x+drivfor*Sin(vaz)
  3217.         vy_f=replay(rep_pnt)\y+drivfor*Cos(vaz)
  3218.         vz_f=replay(rep_pnt)\z-driver_height*Cos(vay)-Abs(slopex)
  3219.         odvx_f=dvx_f
  3220.         odvy_f=dvy_f
  3221.         odvz_f=dvz_f
  3222.         dvx_f=vx_f-ovx_f
  3223.         dvy_f=vy_f-ovy_f
  3224.         dvz_f=vz_f-ovz_f
  3225.         d2vx_f=dvx_f-odvx_f
  3226.         d2vy_f=dvy_f-odvy_f
  3227.         d2vz_f=dvz_f-odvz_f
  3228.         vx_u-d2vx_f
  3229.         vy_u-d2vy_f
  3230.         vz_u-d2vz_f
  3231.         vx=vx_f+vx_u
  3232.         vy=vy_f+vy_u
  3233.         vz=vz_f+vz_u
  3234.  
  3235.         vx_u*.75
  3236.         vy_u*.75
  3237.         vz_u*.75
  3238.         If RawStatus($14)
  3239.           drivfor+1
  3240.         EndIf
  3241.         If RawStatus($15)
  3242.           drivfor-1
  3243.         EndIf
  3244.         drivfor=QLimit(drivfor,-50,50)
  3245.       Case 2
  3246.  
  3247. ;        uvaz_m*.9
  3248.         vaz_m=QWrap(vaz_m+uvaz_m*.0125,0,Pi*2)
  3249.         uvaz_m+(MouseXSpeed)*.125
  3250.         uvaz_m*.75
  3251.  
  3252.         vz_m+uvz_m
  3253.         uvz_m+(MouseYSpeed)*.125
  3254.         uvz_m*.75
  3255.  
  3256. ;        vax=0;replay(rep_pnt)\ax
  3257.         vay=0;replay(rep_pnt)\ay
  3258.         vaz2=replay(rep_pnt)\az
  3259.         vx_c=replay(rep_pnt)\x-replview*Sin(vaz2+vaz_m)
  3260.         vy_c=replay(rep_pnt)\y-replview*Cos(vaz2+vaz_m)
  3261.         vz_c=replay(rep_pnt)\z-vz_m
  3262.         vx+(vx_c-vx)*.25
  3263.         vy+(vy_c-vy)*.25
  3264.         vz+(vz_c-vz)*.25
  3265.         If RawStatus($14)
  3266.           replview+1
  3267.         EndIf
  3268.         If RawStatus($15)
  3269.           replview-1
  3270.         EndIf
  3271.         replview=QLimit(replview,50,200)
  3272.         vaz_c=Pi/2-Pi*2*QAngle(vx,vy,replay(rep_pnt)\x,replay(rep_pnt)\y)
  3273.  
  3274.         targety=Sqr((replay(rep_pnt)\x-vx)^2+(replay(rep_pnt)\y-vy)^2)
  3275.         vax_c=(-Pi*2*QAngle(0,vz,targety,replay(rep_pnt)\z))
  3276.         vaz+QWrap(vaz_c-vaz,-Pi,Pi)*.1
  3277.         vax=vax_c;QWrap(vax_c-vax,-Pi,Pi)*.1
  3278.     End Select
  3279.   tr_vx=QLimit(vx/32+640,0,1023)
  3280.   tr_vy=QLimit(vy/32+640,0,1023)
  3281.   map_slip=slippery(tr_vx,tr_vy)
  3282.     Gosub move_view
  3283.     Gosub move_objects
  3284.     Gosub move_points
  3285.     Gosub rotate_points
  3286. ;    Gosub calc3d
  3287.     Gosub point_display
  3288.     Gosub line_display
  3289.     If RawStatus($33)
  3290.       camera_type=QWrap(camera_type+1,0,3)
  3291.     EndIf
  3292.     CNIF #SYSTEM_FRIENDLY=0
  3293.     VWait
  3294.     ;ShowScreen db+1
  3295.     Show db
  3296.     db=1-db
  3297.  
  3298.     nofcounts+1
  3299.     Use BitMap db
  3300.     Cls
  3301.     BitMapOutput db
  3302.     CELSE
  3303.     VWait
  3304.     WCls
  3305.     CEND
  3306.  
  3307.     rep_n+1
  3308.   Until rep_n>1000 OR Joyb(0)<>0
  3309.   tr_vy=otr_vy
  3310.   tr_vx=otr_vx
  3311.   vx=cachex
  3312.   vy=cachey
  3313.   vz=cachez
  3314.   vax=cacheax
  3315.   vay=cacheay
  3316.   vaz=cacheaz
  3317.   replay=False
  3318.   LoopSound 0,1
  3319.   Volume 1|2|4|8,0,0,0,0
  3320.   Return
  3321. .move_view
  3322.  
  3323.   vay=QWrap(vay,0,p2)
  3324.   vaz=QWrap(vaz,0,p2)
  3325.   vax=QWrap(vax,0,p2)
  3326.  
  3327.   cvaz=Cos(vaz)
  3328.   svaz=Sin(vaz)
  3329.   cvay=Cos(vay)
  3330.   svay=Sin(vay)
  3331.   cvax=Cos(vax)
  3332.   svax=Sin(vax)
  3333.  
  3334. Return
  3335.  
  3336.  
  3337. .move_objects
  3338.  
  3339.  
  3340. ;NEWTYPE .vobj
  3341. ;  x.q:y:z
  3342. ;  ax:ay:az
  3343. ;  obj_start.w
  3344. ;  obj_end.w
  3345. ;End NEWTYPE
  3346.  
  3347. ;   vx=replay(rep_pnt)\x+drivfor*Sin(vaz)
  3348. ;        vy=replay(rep_pnt)\y+drivfor*Cos(vaz)
  3349.     soax=Sin(vec_obj(0)\ax)
  3350.     coax=Cos(vec_obj(0)\ax)
  3351.     soay=Sin(vec_obj(0)\ay)
  3352.     coay=Cos(vec_obj(0)\ay)
  3353.     soaz=Sin(vec_obj(0)\az)
  3354.     coaz=Cos(vec_obj(0)\az)
  3355. ;
  3356. ;vec_obj(1)\x=vec_obj(0)\x+30*soaz-16*coaz
  3357. ;vec_obj(1)\y=vec_obj(0)\y+30*coaz+16*soaz
  3358. ;vec_obj(1)\z=vec_obj(0)\z
  3359. ;vec_obj(1)\ax=vec_obj(0)\ax
  3360. ;vec_obj(1)\ay=vec_obj(0)\ay
  3361. ;vec_obj(1)\az=vec_obj(0)\az
  3362. ;
  3363. ;vec_obj(2)\x=vec_obj(0)\x+30*soaz+16*coaz
  3364. ;vec_obj(2)\y=vec_obj(0)\y+30*coaz-16*soaz
  3365. ;vec_obj(2)\z=vec_obj(0)\z
  3366. ;vec_obj(2)\ax=vec_obj(0)\ax
  3367. ;vec_obj(2)\ay=vec_obj(0)\ay
  3368. ;vec_obj(2)\az=vec_obj(0)\az
  3369. ;
  3370. ;vec_obj(3)\x=vec_obj(0)\x-30*soaz-16*coaz
  3371. ;vec_obj(3)\y=vec_obj(0)\y-30*coaz+16*soaz
  3372. ;vec_obj(3)\z=vec_obj(0)\z
  3373. ;vec_obj(3)\ax=vec_obj(0)\ax
  3374. ;vec_obj(3)\ay=vec_obj(0)\ay
  3375. ;vec_obj(3)\az=vec_obj(0)\az
  3376. ;
  3377. ;vec_obj(4)\x=vec_obj(0)\x-30*soaz+16*coaz
  3378. ;vec_obj(4)\y=vec_obj(0)\y-30*coaz-16*soaz
  3379. ;vec_obj(4)\z=vec_obj(0)\z
  3380. ;vec_obj(4)\ax=vec_obj(0)\ax
  3381. ;vec_obj(4)\ay=vec_obj(0)\ay
  3382. ;vec_obj(4)\az=vec_obj(0)\az
  3383.  
  3384.   points3=points
  3385.   points3a=points3
  3386.   lines=olines:polygons=opolygons
  3387.   For m=0 To 0
  3388.     soax=Sin(-vec_obj(m)\ax)
  3389.     coax=Cos(-vec_obj(m)\ax)
  3390.     soay=Sin(-vec_obj(m)\ay)
  3391.     coay=Cos(-vec_obj(m)\ay)
  3392.     soaz=Sin(-vec_obj(m)\az)
  3393.     coaz=Cos(-vec_obj(m)\az)
  3394.  
  3395.  
  3396.     For n=vec_obj(m)\obj_start To vec_obj(m)\obj_end
  3397.  
  3398.       xx=obx(n)ASL 8
  3399.       yy=oby(n)ASL 8
  3400.       zz=obz(n)ASL 8
  3401.  
  3402.       xx1=xx*coay-zz*soay
  3403.       zz1=zz*coay+xx*soay
  3404.       yy1=yy*coax-zz*soax
  3405.       robz(n)=zz1*coax+yy*soax
  3406.       robx(n)=xx1*coaz-yy1*soaz
  3407.       roby(n)=yy1*coaz+xx1*soaz
  3408.     Next n
  3409.  
  3410.     For n=vec_obj(m)\obj_start To vec_obj(m)\obj_end
  3411.       points3+1
  3412.       px(points3)=(robx(n)ASR8)+vec_obj(m)\x
  3413.       py(points3)=(roby(n)ASR8)+vec_obj(m)\y
  3414.       pz(points3)=(robz(n)ASR8)+vec_obj(m)\z
  3415.     Next n
  3416.  
  3417.     If object_appears=0 AND racing=True
  3418. ;      lines=olines
  3419.       For n=1 To 10
  3420.         lines+1
  3421.         lin(lines)\l1=pnt(points3a+obln(n,1))
  3422.         lin(lines)\l2=pnt(points3a+obln(n,2))
  3423.         lin(lines)\col=2
  3424.       Next n
  3425.     Else
  3426. ;      polygons=opolygons
  3427.       objnorm=Abs(soax*soay)
  3428.       For n=1 To #CAR_POLYS
  3429.         polygons+1
  3430.         pol(polygons)\p1=pnt(points3a+obpol(n,1))
  3431.         pol(polygons)\p2=pnt(points3a+obpol(n,2))
  3432.         pol(polygons)\p3=pnt(points3a+obpol(n,3))
  3433.         pol(polygons)\p4=pnt(points3a+obpol(n,4))
  3434.         tcol=obpolcol(n)
  3435.         If tcol=2
  3436.           If nofcolours>4
  3437.             tnorm=1-(objnorm);-obpolnorm(n))
  3438.             tdnorm=256*tnorm-226
  3439.             tcol=col_list(0,QLimit(tdnorm,0,31))
  3440. ;            If tcol<=4 Then tcol=2
  3441.           EndIf
  3442.         EndIf
  3443.         pol(polygons)\col=tcol
  3444.  
  3445.       Next n
  3446.     EndIf
  3447.     points3a=points3
  3448.   Next m
  3449.  
  3450.  
  3451.  
  3452. ; Dynamic Landscape Point Generation
  3453. ; ==================================
  3454.  
  3455.   points4=points3
  3456. If landscape_on=True
  3457.  
  3458.   rc_vx=1280+(Int((tr_vx-720)/4)) ASL 7
  3459.   For m=Int(tr_vx)-40 To Int(tr_vx)+36 Step 4
  3460.     rc_vy=1280+(Int((tr_vy-720)/4)) ASL 7
  3461.     For n=Int(tr_vy)-40 To Int(tr_vy)+36 Step 4
  3462.  
  3463.       hmx.w=m ASR 2
  3464.       hmy.w=n ASR 2
  3465.  
  3466.       If RectsHit(hmx,hmy,1,1,0,0,255,255)
  3467.         If heightmap(hmx,hmy)=0
  3468.           map_slip=slippery(m,n)
  3469.           heightmap(hmx,hmy)=land1{rc_vx,rc_vy}
  3470.         EndIf
  3471.         points4+1
  3472.         px(points4)=rc_vx
  3473.         py(points4)=rc_vy
  3474.         pz(points4)=heightmap(hmx,hmy)
  3475.       Else
  3476.         points4+1
  3477.         px(points4)=rc_vx
  3478.         py(points4)=rc_vy
  3479.         pz(points4)=4000;heightmap(hmx,hmy)
  3480.       EndIf
  3481.       rc_vy+128
  3482.  
  3483.     Next n
  3484.     rc_vx+128
  3485.   Next m
  3486.  
  3487.  
  3488.  
  3489.  
  3490.   max_dblcol=0
  3491.   min_dblcol=0
  3492.   lpolygons=polygons
  3493.   db_lpol=(hmx+hmy) MOD 2
  3494.   For m=points3+1 To points4-10 Step 20
  3495.     For n=m To m+18 Step 1
  3496.         lpolygons+1
  3497.         pol(lpolygons)\p1=pnt(n)
  3498.         pol(lpolygons)\p2=pnt(n+1)
  3499.         pol(lpolygons)\p3=pnt(n+21)
  3500.         pol(lpolygons)\p4=pnt(n+20)
  3501.         db_lcol=QAbs(pz(n)-pz(n+1))
  3502.         db_lcol+QAbs(pz(n+20)-pz(n+21))
  3503.         db_lcol+QAbs(pz(n)-pz(n+20))
  3504.         db_lcol+QAbs(pz(n+1)-pz(n+21))
  3505.         db_lcol ASR 5
  3506.  
  3507. ;        max_dblcol=Max(max_dblcol,db_lcol)
  3508. ;        min_dblcol=Min(min_dblcol,db_lcol)
  3509.         If nofcolours>4
  3510.           pol(lpolygons)\col=QLimit(15-db_lcol,5,15)
  3511.         Else
  3512.           pol(lpolygons)\col=db_lpol
  3513.         EndIf
  3514.         If db_lpol=1 Then db_lpol=3 Else db_lpol=1
  3515.     If lconnect=10 Then lconnect=0
  3516.     Next n
  3517.   Next m
  3518.  
  3519. EndIf
  3520.  
  3521.  
  3522.  
  3523.  
  3524. Return
  3525.  
  3526. .move_points
  3527.  
  3528.   CNIF #DBUG=1
  3529.     Runerrsoff
  3530.   CEND
  3531.   vxmin1=QLimit(vx-300,-32000,32000)
  3532.   vymin1=QLimit(vy-300,-32000,32000)
  3533.  
  3534.  
  3535.   vxmin2=QLimit(vx-max_distancing/4,-32000,32000)
  3536.   vymin2=QLimit(vy-max_distancing/4,-32000,32000)
  3537.   vxmax2=max_distancing/2
  3538.  
  3539.   vxmin3=QLimit(vx-max_distancing,-32000,32000)
  3540.   vymin3=QLimit(vy-max_distancing,-32000,32000)
  3541.   vxmax3=2*max_distancing
  3542.  
  3543.   vxmin4=QLimit(vx-max_distancing/16,-32000,32000)
  3544.   vymin4=QLimit(vy-max_distancing/16,-32000,32000)
  3545.   vxmax4=max_distancing/8
  3546.  
  3547.   back_points=QLimit(point_distancing/2,40,120)
  3548.  
  3549.   oclose_point_ratio=close_point_ratio
  3550.   close_point_ratio=(close_point_ratio*7+closest_point-oclosest_point)/8
  3551. ;  close_point_ratio=closest_point-oclosest_point
  3552.   If close_point_ratio>1+oclose_point_ratio
  3553.     closest_point=oclosest_point+oclose_point_ratio
  3554.   EndIf
  3555.  
  3556.   oclosest_point=closest_point
  3557.  
  3558.   start_point=QLimit(closest_point-back_points,1,point_start)
  3559.  
  3560.   end_point=QLimit(closest_point+point_distancing*2,point_end,points1-1)
  3561.   point_start=points1-1
  3562.   point_end=1
  3563.   found_points=False
  3564. ;  For n=1 To start_point
  3565. ;    oapp(n)=0
  3566. ;  Next n
  3567.   templ.l=start_point-1
  3568.  
  3569.  
  3570.   GetReg a0,&oapp(1)
  3571.   GetReg d0,templ
  3572.  
  3573. _asm_move_loop1:
  3574.   MOVE.b #0,(a0)+
  3575.   SUBQ.l #1,d0
  3576.   BGE _asm_move_loop1
  3577.  
  3578.  
  3579. CNIF1=1
  3580.  
  3581.   n=start_point
  3582.   tempw.w=end_point-start_point
  3583.   GetReg d2,&px(n)
  3584.   GetReg d1,&ox(n)
  3585.   GetReg d0,tempw
  3586.   GetReg d3,&vx
  3587.   MOVE.l d3,a3
  3588.   MOVE.l (a3),d3
  3589.   MOVE.l d1,a0
  3590.   MOVE.l d2,a1
  3591. _move_pnt1:
  3592.   MOVE.l (a1)+,d4
  3593.   SUB.l d3,d4
  3594.   ASL.l #3,d4
  3595.   MOVE.l d4,(a0)+
  3596.   DBRA d0,_move_pnt1
  3597.  
  3598.   GetReg d2,&py(n)
  3599.   GetReg d1,&oy(n)
  3600.   GetReg d0,tempw
  3601.   GetReg d3,&vy
  3602.   MOVE.l d3,a3
  3603.   MOVE.l (a3),d3
  3604.   MOVE.l d1,a0
  3605.   MOVE.l d2,a1
  3606. _move_pnt2:
  3607.   MOVE.l (a1)+,d4
  3608.   SUB.l d3,d4
  3609.   ASL.l #3,d4
  3610.   MOVE.l d4,(a0)+
  3611.   DBRA d0,_move_pnt2
  3612.  
  3613.   GetReg d2,&pz(n)
  3614.   GetReg d1,&oz(n)
  3615.   GetReg d0,tempw
  3616.   GetReg d3,&vz
  3617.   MOVE.l d3,a3
  3618.   MOVE.l (a3),d3
  3619.   MOVE.l d1,a0
  3620.   MOVE.l d2,a1
  3621. _move_pnt3:
  3622.   MOVE.l (a1)+,d4
  3623.   SUB.l d3,d4
  3624.   ASL.l #3,d4
  3625.   MOVE.l d4,(a0)+
  3626.   DBRA d0,_move_pnt3
  3627.  
  3628.   GetReg d4,&found_points
  3629.   GetReg d3,&oapp(n)
  3630.   GetReg d2,&oy(n)
  3631.   GetReg d1,&ox(n)
  3632.   GetReg d0,tempw
  3633.   MOVE.l d1,a1
  3634.   MOVE.l d2,a2
  3635.   MOVE.l d3,a0
  3636.   MOVE.l d4,a3
  3637. ;_move_pnt4:
  3638. ;  MOVE.l (a1)+,d1
  3639. ;  MOVE.l (a2)+,d2
  3640. ;  SWAP d1
  3641. ;  SWAP d2
  3642. ;  CMP.w #4096,d1
  3643. ;  SLT d4
  3644. ;  CMP.w #-4096,d1
  3645. ;  SLT d5
  3646. ;  AND.b d4,d5
  3647. ;  CMP.w #4096,d2
  3648. ;  SLT d4
  3649. ;  CMP.w #-4096,d2
  3650. ;  SLT d6
  3651. ;  AND.b d4,d6
  3652. ;  AND.b d5,d6
  3653. ;  MOVE.b d6,(a3)+
  3654. ;
  3655. ;  DBRA d0,_move_pnt4
  3656.  
  3657. CEND
  3658.  
  3659.  
  3660.   n=start_point
  3661.   close_point=0
  3662.   close_point_dist=200
  3663.   Repeat
  3664.     Select point_value(n)
  3665.       Case 1
  3666.         If RectsHit(vxmin2,vymin2,vxmax2,vxmax2,px(n),py(n),1,1)
  3667. ;          ox(n)=(px(n)-vx)
  3668. ;          oy(n)=(py(n)-vy)
  3669. ;          oz(n)=(pz(n)-vz)
  3670.           oapp(n)=1
  3671.           close_point_dist1=QAbs((px(n)ASR7)-(vx ASR7))+QAbs((py(n)ASR7)-(vy ASR7))
  3672.           If close_point_dist1>0
  3673.           If close_point_dist1<close_point_dist
  3674.             close_point_dist=close_point_dist1
  3675.             closest_point=n
  3676.             cd_closest_point=n
  3677.             If close_point=0 Then close_point=n
  3678.             found_points=True
  3679.           EndIf
  3680.           EndIf
  3681.         EndIf
  3682.  
  3683.       Case 2
  3684.         If RectsHit(vxmin3,vymin3,vxmax3,vxmax3,px(n),py(n),1,1)
  3685. ;          ox(n)=(px(n)-vx)
  3686. ;          oy(n)=(py(n)-vy)
  3687. ;          oz(n)=(pz(n)-vz)
  3688.           oapp(n)=1
  3689.           ;found_points=True
  3690.         EndIf
  3691.  
  3692.       Case 3
  3693.         If RectsHit(vxmin4,vymin4,vxmax4,vxmax4,px(n),py(n),1,1)
  3694. ;          ox(n)=(px(n)-vx)
  3695. ;          oy(n)=(py(n)-vy)
  3696. ;          oz(n)=(pz(n)-vz)
  3697.           oapp(n)=1
  3698.         EndIf
  3699.  
  3700.  
  3701.  
  3702.       Case 0
  3703.         If RectsHit(vxmin1,vymin1,600,600,px(n),py(n),1,1)
  3704. ;          ox(n)=(px(n)-vx)
  3705. ;          oy(n)=(py(n)-vy)
  3706. ;          oz(n)=(pz(n)-vz)
  3707.           oapp(n)=1
  3708. ;          closest_point=n
  3709. ;        Else
  3710. ;          oapp(n)=0
  3711.         EndIf
  3712.  
  3713. ;      Default
  3714. ;        ox(n)=(px(n)-vx)
  3715. ;        oy(n)=(py(n)-vy)
  3716. ;        oz(n)=(pz(n)-vz)
  3717. ;        oapp(n)=0
  3718.  
  3719.     End Select
  3720.  
  3721.  
  3722.     n+1
  3723.   Until n>end_point
  3724.  
  3725.   For n=end_point To points1-1
  3726.     oapp(n)=0
  3727.   Next n
  3728.  
  3729.   If found_points=False Then point_start=0:point_end=points1-1
  3730.  
  3731.  
  3732.  
  3733.   objn=0
  3734.  
  3735.  
  3736.  
  3737.  
  3738.  
  3739.  
  3740.  
  3741.  
  3742.  
  3743.   obj_dx=vec_obj(0)\x-vx
  3744.   obj_dy=vec_obj(0)\y-vy
  3745.   If (QAbs(obj_dx)+QAbs(obj_dy))<80 AND replay=False
  3746.     object_appears=0
  3747.   Else
  3748.     object_appears=1
  3749.     If QAbs(obj_dx)+QAbs(obj_dy)<4000
  3750.       aslam=4
  3751.     Else
  3752.       aslam=0
  3753.     EndIf
  3754.   EndIf
  3755.   For n=points+1 To points3
  3756.     objn+1
  3757.     ox(n)=(px(n)-vx)ASL aslam
  3758.     oy(n)=(py(n)-vy)ASL aslam
  3759.     oz(n)=(pz(n)-vz)ASL aslam
  3760.     oapp(n)=1;object_appears
  3761.   Next n
  3762.  
  3763.  
  3764. ;   Dynamic Landscape Points
  3765. ;   ========================
  3766.  
  3767.   For n=points3+1 To points4
  3768.     ox(n)=px(n)-vx
  3769.     oy(n)=py(n)-vy
  3770.     oz(n)=pz(n)-vz
  3771.     oapp(n)=1
  3772.   Next n
  3773.  
  3774. ; Far-Away Mountain Points
  3775. ; ========================
  3776.  
  3777.  
  3778.   tmpx=vx/4  ;trick to make them
  3779.   tmpy=vy/4  ;look as if they really
  3780.   tmpz=vz/4  ;are far away
  3781.  
  3782.   For n=points1 To points
  3783.     ox(n)=px(n)-tmpx
  3784.     oy(n)=py(n)-tmpy
  3785.     oz(n)=pz(n)-tmpz
  3786.     oapp(n)=1
  3787.   Next n
  3788.   CNIF #DBUG=1
  3789.     Runerrson
  3790.   CEND
  3791. Return
  3792.  
  3793.  
  3794.  
  3795.  
  3796. .rotate_points
  3797.  
  3798.  
  3799.  
  3800.   tempword.w=points4
  3801.   chckpnts1.l=tempword
  3802.   chckpnts2.l=0
  3803.   #ROTSCALE=32767
  3804.   sincache(0)=cvaz*#ROTSCALE
  3805.   sincache(1)=svaz*#ROTSCALE
  3806.   sincache(2)=cvax*#ROTSCALE;Cos(vax*2)*#ROTSCALE
  3807.   sincache(3)=svax*#ROTSCALE;Sin(vax*2)*#ROTSCALE
  3808.   sincache(4)=cvay*#ROTSCALE
  3809.   sincache(5)=svay*#ROTSCALE
  3810.   sincache(6)=18-zoom_factor
  3811.   sincache(7)=160
  3812.   sincache(8)=80
  3813.  
  3814.  
  3815.   CNIF #DBUG=1
  3816.     Runerrsoff
  3817.   CEND
  3818.                                                                                                                               
  3819.   GetReg a0,&ox(1)
  3820.   GetReg a1,&oy(1)
  3821.   GetReg a2,&oz(1)
  3822.   GetReg a3,&oapp(1)
  3823.   GetReg d2,&sincache(0)
  3824.   GetReg d1,&pnt(1)
  3825.   GetReg a4,&tempword
  3826.   INCDIR "WRECKAGE:SOURCE/ASSEMBLY/"
  3827.   IncBin "asm_3d_s2c"
  3828.   PutReg d0,chckpnts2
  3829.   CNIF #DBUG=1
  3830.     Runerrson
  3831.   CEND
  3832.  
  3833. end_assembly:
  3834.  
  3835.  
  3836. Return
  3837.  
  3838.  
  3839.  
  3840.   ;Runerrson
  3841.  
  3842.  
  3843.  
  3844. .calc3d
  3845.   If replay=False Then replay_zoom=0
  3846.   zoom_factory.b=zoom_factor+replay_zoom-6
  3847.   zoom_factorx.b=zoom_factor+replay_zoom-6
  3848.   zoom_magy=2^zoom_factor
  3849.   zoom_magx=zoom_magy
  3850.  
  3851.   offsetscx3=3*offsetscx
  3852.   offsetscy3=3*offsetscy
  3853.   doffsetscx=6*offsetscx
  3854.   doffsetscy=6*offsetscy
  3855.   For n=1 To points3
  3856.     If pnt(n)\app<>0
  3857.       pnt(n)\sx=offsetscx+QLimit(((pnt(n)\sx)ASR zoom_factorx),-offsetscx3,offsetscx3)
  3858.       pnt(n)\sy=offsetscy+QLimit(((pnt(n)\sy)ASR zoom_factory),-offsetscy3,offsetscy3)
  3859.     EndIf
  3860.  
  3861.   Next n
  3862.  
  3863.  
  3864. Return
  3865.  
  3866. .point_display
  3867.  
  3868. CNIF1=0
  3869.   lconnect=0
  3870.   For n=points3+1 To points4-1
  3871.     lconnect+1
  3872.     If pnt(n)\app=1
  3873.  
  3874.       If pnt(n+10)\app=1
  3875.         Line pnt(n)\sx,pnt(n)\sy,pnt(n+10)\sx,pnt(n+10)\sy,3
  3876.       EndIf
  3877.  
  3878.       If lconnect<10
  3879.         If pnt(n+1)\app=1
  3880.           Line pnt(n)\sx,pnt(n)\sy,pnt(n+1)\sx,pnt(n+1)\sy,3
  3881.         EndIf
  3882.       EndIf
  3883.  
  3884.     EndIf
  3885.     If lconnect=10 Then lconnect=0
  3886.   Next n
  3887. CEND
  3888. ;  pd1=QLimit(cd_closest_point-12,1,points1)
  3889. ;  pd2=QLimit(cd_closest_point+12,1,points1)
  3890. ;  For n=pd1 To pd2
  3891. ;    Circlef pnt(n)\sx,pnt(n)\sy,2,1
  3892. ;  Next n
  3893.   Return
  3894.  
  3895. .line_display
  3896. CNIF #DBUG=1
  3897.   Runerrsoff
  3898. CEND
  3899. CNIF #SYSTEM_FRIENDLY=0
  3900.  
  3901. If replay=False
  3902.   Locate 10,1
  3903.   NPrint Int(ruy*4)
  3904.   Locate 20,1
  3905.   NPrint gear
  3906. ;  NPrint turbovol
  3907. ;  NPrint showthis1
  3908. ;  NPrint showthis2
  3909. ;  NPrint showthis3
  3910. ;  NPrint raw_thrust_effect
  3911. ;  NPrint raw_thrust
  3912. ;  NPrint wheel_speed
  3913.  
  3914.   ;raw_thrust_effect=(raw_thrust-wheel_speed/20000)*gear_ratio
  3915.  
  3916. ;  NPrint svax,", ",svay
  3917. ;  NPrint svax2,", ",svay2
  3918. ;  NPrint drivfor
  3919. ;  NPrint drvax
  3920. ;  NPrint frame_speed
  3921.   ;NPrint objnorm,":",coax,"*",coay
  3922. ;  NPrint volword
  3923. ;  NPrint vuz, ",", vz
  3924. ;  NPrint add_vuz
  3925. ;  NPrint "X:",svax,",Y:",svay
  3926. ;  NPrint "X:",add_vuzx,"Y:",add_vuzy
  3927.  
  3928. ;  NPrint polygons
  3929. ;  NPrint points4
  3930. ;;  NPrint mod_tyr_freq
  3931. ;  NPrint tyrfreq
  3932.  
  3933. ;  NPrint ctrl\dx
  3934. ;  NPrint ctrl\d2x
  3935. ;  NPrint ctrl\d3x
  3936. ;  NPrint ctrl\force
  3937. ;  NPrint ctrl\a
  3938.  
  3939. ;  NPrint max_dblcol
  3940. ;  NPrint min_dblcol
  3941.  
  3942.  
  3943.  
  3944.  
  3945.   If extra_display_info
  3946.   NPrint fmountcnt
  3947.   NPrint vy/100-mountycnt1
  3948.   NPrint vx/100-mountxcnt1
  3949.   NPrint vz
  3950.     NPrint "F   ",QLimit(QAbs(unreal_speed*gear_ratio)/8,.1,100)
  3951.     NPrint "Bef ",brake_effectiveness
  3952.     NPrint "PoC ",brake_temperature
  3953.     NPrint "Fef ",fluid_effectiveness
  3954.     NPrint "FoC ",fluid_temperature
  3955.     NPrint "Kgm ",xtra_boost
  3956.   EndIf
  3957.   If engfreq<>0 Then  engang=140/engfreq
  3958.   engang=-6*engang
  3959.   ;Circle 300,16,16,1
  3960.   Blit 0,284,0
  3961.   Line 300,16,300+16*Sin(engang),16+16*Cos(engang),2
  3962.  
  3963. ;Else
  3964. ;  Locate 1,1
  3965. ;  NPrint camera_type
  3966. ;  NPrint objnorm,":",coax,"*",coay
  3967. ;  NPrint tnorm,"->",tdnorm
  3968. ;  NPrint vaz_m
  3969. ;;  NPrint vax_c
  3970.  
  3971. EndIf
  3972. CEND
  3973.  
  3974.   USEPATH pol(n)
  3975.   dis_polys=0
  3976.   polydb=0
  3977.  
  3978. USEPATH lin(n)
  3979. CNIF1=1
  3980.   For n=1 To hor_lin_end
  3981.     If \l1\app=1 AND \l2\app=1
  3982.         CNIF #SYSTEM_FRIENDLY=0
  3983.         Line \l1\sx,\l1\sy,\l2\sx,\l2\sy,\col
  3984.         CELSE
  3985.         Wline \l1\sx,\l1\sy,\l2\sx,\l2\sy,\col
  3986.         CEND
  3987.     EndIf
  3988.   Next n
  3989. ;
  3990. CELSE
  3991.   tempw.w=hor_lin_end-1
  3992.   GetReg d7,tempw
  3993.   GetReg d0,&lin(1)
  3994.   MOVE.l d0,a0
  3995.   SUBQ #1,d7
  3996.   JSR _draw_line1
  3997.  
  3998. CEND
  3999.  
  4000.   Gosub draw_landscape
  4001.   Gosub draw_road
  4002.  
  4003.  
  4004.   USEPATH lin(n)
  4005. CNIF1=1
  4006.   For n=hor_lin_end To lines
  4007.     If \l1\app=1 AND \l2\app=1
  4008.         CNIF #SYSTEM_FRIENDLY=0
  4009.         Line \l1\sx,\l1\sy,\l2\sx,\l2\sy,\col
  4010.         CELSE
  4011.         Wline \l1\sx,\l1\sy,\l2\sx,\l2\sy,\col
  4012.         CEND
  4013.     EndIf
  4014.   Next n
  4015. ;
  4016. CELSE
  4017.  
  4018.   tempw.w=lines-hor_lin_end-1
  4019.   GetReg d7,tempw
  4020.   GetReg d0,&lin(hor_lin_end+1)
  4021.   MOVE.l d0,a0
  4022.   SUBQ #1,d7
  4023.   JSR _draw_line1
  4024.  
  4025.  
  4026. CEND
  4027.  
  4028. CNIF1=1
  4029.   USEPATH pol(n)
  4030.   For n=opolygons+1 To polygons
  4031.     If \p1\app=1 AND \p2\app=1 AND \p3\app=1 AND \p4\app=1
  4032.       dis_polys+1
  4033.       polybuff(0)=\p1\sx
  4034.       polybuff(1)=\p1\sy
  4035.       polybuff(2)=\p2\sx
  4036.       polybuff(3)=\p2\sy
  4037.       polybuff(4)=\p3\sx
  4038.       polybuff(5)=\p3\sy
  4039.       polybuff(6)=\p4\sx
  4040.       polybuff(7)=\p4\sy
  4041.       polybuff(8)=polybuff(0)
  4042.       polybuff(9)=polybuff(1)
  4043.       Gosub clip2
  4044.       CNIF #SYSTEM_FRIENDLY=0
  4045.       Polyf 3,&polybuff(0),\col,-1
  4046.       Polyf 3,&polybuff(4),\col,-1
  4047.       CELSE
  4048.       crapthing.l=PolyDraw_(myrastport,4,&polybuff(0))
  4049.       CEND
  4050.     EndIf
  4051.   Next n
  4052. CELSE
  4053.  
  4054.   tempw.w=polygons-opolygons
  4055.   GetReg d7,tempw
  4056.   GetReg d6,&pol(opolygons+1)
  4057.   GetReg d5,&polybuff(0)
  4058.   MOVE.l d6,a0
  4059.   MOVE.l d5,a1
  4060.   SUBQ.w #1,d7
  4061.  
  4062.   JSR draw_polys
  4063.  
  4064. CEND
  4065.  
  4066.  
  4067.   CNIF #SYSTEM_FRIENDLY=0
  4068.  
  4069.   If replay=False
  4070. ;      Polyf 4,&hood(0),2
  4071.     If nofcolours>4
  4072.       Blit 2,0,160-ShapeHeight(2)
  4073.     Else
  4074.       Blit 1,0,160-ShapeHeight(1)
  4075.     EndIf
  4076.     Box 157,152,163,159,3
  4077.     Boxf 158+turn_raw*4,153,162+turn_raw*4,158,1
  4078.     Box 158+turn_raw*4,153,162+turn_raw*4,158,2
  4079.  
  4080.   EndIf
  4081.   CEND
  4082.   CNIF #DBUG=1
  4083.     Runerrson
  4084.   CEND
  4085. Return
  4086.  
  4087. .draw_road
  4088.   USEPATH pol(n)
  4089.   dis_polys=0
  4090.   polydb=0
  4091.  
  4092. CNIF1=0
  4093.   For n=opolygons To 1 Step -1
  4094.     If \p1\app=1 AND \p3\app=1
  4095.         If \p2\app=1 AND \p2\app=1
  4096.           GetReg d7,&pol(n)
  4097.           GetReg d1,&polybuff(0)
  4098.           MOVE.l d7,a0
  4099.           MOVE.l d1,a1
  4100.           MOVE.l (a0)+,a2
  4101.           MOVE.l (a0)+,a3
  4102.           MOVE.l (a2),(a1)+
  4103.           MOVE.l (a3),(a1)+
  4104.           MOVE.l (a0)+,a2
  4105.           MOVE.l (a0)+,a3
  4106.           MOVE.l (a2),(a1)+
  4107.           MOVE.l (a3),(a1)+
  4108.           MOVE.w (a0)+,d2
  4109.           MOVE.l #4,d0
  4110.           MOVE.l #-1,d3
  4111.           TokeJsr Polyf,2
  4112.         EndIf
  4113.     EndIf
  4114.   Next n
  4115.  
  4116. CELSE
  4117.   tempw.w=opolygons
  4118.   GetReg d7,tempw
  4119.   GetReg d6,&pol(1)
  4120.   GetReg d5,&polybuff(0)
  4121.   MOVE.l d6,a0
  4122.   MOVE.l d5,a1
  4123.   SUBQ.w #1,d7
  4124.  
  4125.   JSR draw_polys
  4126.  
  4127. CEND
  4128.   Return
  4129.  
  4130.  
  4131.  
  4132.  
  4133. .draw_the_lines
  4134.  
  4135.  
  4136.  
  4137. _draw_line1:
  4138.   MOVE.l (a0)+,a1
  4139.   MOVE.l (a0)+,a2
  4140.   MOVE.w (a0)+,d4
  4141.   MOVE.l (a1)+,d0
  4142.   MOVE.l (a2)+,d2
  4143.   MOVE.w (a1),d6
  4144.   AND.w (a2),d6
  4145.   BEQ _draw_line1a
  4146.   MOVE.w d0,d1
  4147.   MOVE.w d2,d3
  4148.   EXT.l d1
  4149.   EXT.l d3
  4150.   CLR.w d0
  4151.   CLR.w d2
  4152.   SWAP d0
  4153.   SWAP d2
  4154.   EXT.l d0
  4155.   EXT.l d2
  4156.   MOVEM.l a0/d7,-(a7)
  4157.   TokeJsr Line
  4158.   MOVEM.l (a7)+,a0/d7
  4159. _draw_line1a:
  4160.   DBRA d7,_draw_line1
  4161.  
  4162.   RTS
  4163.  
  4164.  
  4165. .draw_landscape
  4166. If landscape_on=True
  4167. CNIF1=0
  4168.   For n=lpolygons To opolygons Step -1
  4169.     polydb=QWrap(polydb+1,0,9)
  4170.     If \p1\app=1 AND \p3\app=1
  4171.       If \p2\app=1
  4172.         dis_polys+1
  4173.         polybuff(0)=\p1\sx
  4174.         polybuff(1)=\p1\sy
  4175.         polybuff(2)=\p2\sx
  4176.         polybuff(3)=\p2\sy
  4177.         polybuff(4)=\p3\sx
  4178.         polybuff(5)=\p3\sy
  4179.         Gosub clip
  4180.         CNIF #SYSTEM_FRIENDLY=0
  4181.           Polyf 3,&polybuff(0),\col,-1
  4182.         CELSE
  4183.           crapthing.l=PolyDraw_(myrastport,4,&polybuff(0))
  4184.         CEND
  4185.       EndIf
  4186.     EndIf
  4187.   Next n
  4188. CELSE
  4189.   tempw.w=lpolygons-opolygons-1
  4190.   GetReg d7,tempw
  4191.   GetReg d6,&pol(opolygons)
  4192.   GetReg d5,&polybuff(0)
  4193.   MOVE.l d6,a0
  4194.   MOVE.l d5,a1
  4195.   SUBQ.w #1,d7
  4196.   JSR draw_polys
  4197.  
  4198.  
  4199. CEND
  4200. EndIf
  4201. Return
  4202.  
  4203.  
  4204. .draw_polys
  4205.  
  4206. _draw_polys1:
  4207.   MOVE.l (a0)+,a2
  4208.   MOVE.l (a0)+,a3
  4209.   MOVE.l (a2)+,(a1)
  4210.   MOVE.w (a2),d4
  4211.   MOVE.l (a3)+,4(a1)
  4212.   AND.w (a3),d4
  4213.  
  4214.  
  4215.   MOVE.l (a0)+,a2
  4216.   MOVE.l (a0)+,a3
  4217.   MOVE.l (a2)+,8(a1)
  4218.   AND.w (a2),d4
  4219.   MOVE.l (a3)+,12(a1)
  4220.   AND.w (a3),d4
  4221.  
  4222.   MOVE.w (a0)+,d2
  4223.   TST.w d4
  4224.   BEQ _draw_polys2
  4225.   MOVE.l #4,d0
  4226.   MOVE.l a1,d1
  4227.   MOVE.l #-1,d3
  4228.   MOVEM.l a0-a1/d7,-(a7)
  4229.   TokeJsr Polyf,1
  4230.   MOVEM.l (a7)+,a0-a1/d7
  4231. _draw_polys2:
  4232.   DBRA d7,_draw_polys1
  4233.   RTS
  4234.  
  4235.  
  4236.  
  4237. .clip
  4238.   For n0.w=0 To 5
  4239.     polybuff(n0)=QLimit(polybuff(n0),-160,480)
  4240.   Next n0
  4241.   Return
  4242.  
  4243. .clip2
  4244.   For n0.w=0 To 7
  4245.     polybuff(n0)=QLimit(polybuff(n0),-160,480)
  4246.   Next n0
  4247.   Return
  4248.  
  4249.  
  4250.  
  4251.  
  4252.  
  4253. .horizon
  4254.  
  4255.   points1=points+1
  4256.  
  4257.   tmpz=-2000
  4258.   For n=0 To p2 Step .25
  4259.       points+1
  4260.       px(points)=20000*Sin(n)
  4261.       py(points)=20000*Cos(n)
  4262.       pz(points)=tmpz
  4263.       tmpz=QLimit(tmpz+Rnd(2000)-1000,-2000,0)
  4264.  
  4265.   Next n
  4266.  
  4267.   For n=points1 To points-1
  4268.       lines+1
  4269.       lin(lines)\l1=pnt(n)
  4270.       lin(lines)\l2=pnt(n+1)
  4271.       lin(lines)\col=3
  4272.   Next n
  4273.  
  4274.   points2=points+1
  4275.   For n=0 To p2 Step .25
  4276.     points+1
  4277.     tmpdepth=Rnd(5000)+5000
  4278.     px(points)=tmpdepth*Sin(n)+Rnd(1500)
  4279.     py(points)=tmpdepth*Cos(n)+Rnd(1500)
  4280.     pz(points)=200
  4281.   Next n
  4282.  
  4283.   tmpdiff=points2-points1
  4284.   hor_lin_start=lines+1
  4285.   For n=points2 To points-1
  4286.       lines+1
  4287.       lin(lines)\l1=pnt(n)
  4288.       lin(lines)\l2=pnt(n+1)
  4289.       lin(lines)\col=3
  4290.  
  4291.       lines+1
  4292.       lin(lines)\l1=pnt(n)
  4293.       lin(lines)\l2=pnt(n-tmpdiff)
  4294.       lin(lines)\col=3
  4295.  
  4296.   Next n
  4297.   hor_lin_end=lines
  4298.  
  4299.  
  4300.  
  4301. Return
  4302.  
  4303.  
  4304. .sqthing
  4305.   For n=1 To 12 Step 1
  4306.     For m=0 To 11 Step 1
  4307.       points+1
  4308.       px(points)=m*2024+Rnd(500)
  4309.       py(points)=n*2024+Rnd(500)
  4310.       pz(points)=Rnd(400)
  4311.     Next m
  4312.   Next n
  4313.  
  4314.   tempw.w=0
  4315.   lines=0
  4316.   For n=1 To 11
  4317.     For m=0 To 11
  4318.       lines+1
  4319.       lin(lines)\l1=pnt(tempw)
  4320.       lin(lines)\l2=pnt(tempw+1)
  4321.  
  4322.       lines+1
  4323.       lin(lines)\l1=pnt(tempw)
  4324.       lin(lines)\l2=pnt(tempw+13)
  4325.  
  4326.       tempw+1
  4327.     Next m
  4328.     tempw+1
  4329.   Next n
  4330.  
  4331.   Return
  4332.  
  4333. .road
  4334.   Locate 10,2
  4335.   NPrint "Creating Track"
  4336.  
  4337.   map_slip=0
  4338.  
  4339.  
  4340.   f1.f=((Rnd)+.2)*hill_height*4
  4341.   f2.f=((Rnd)+.2)*hill_height*3
  4342. ;  dummy=RTEZRequest("hill "+Str$(hill_height),Str$(f1)+","+Str$(f2),"OK")
  4343.   f3.f=(Rnd-.5)*.5
  4344.   f4.f=(Rnd-.5)*.5
  4345.   f5.f=(Rnd-.5)*.21
  4346.   f6.f=(Rnd-.5)*.25
  4347.   f7.f=(Rnd-.5)*.125
  4348.   f8.f=(Rnd-.5)*.125
  4349.   f9.f=(Rnd-.5)*.0125
  4350.   f10.f=(Rnd-.5)*.0125
  4351.   fmountcnt.f=Rnd*.1+.05
  4352.   mountxcnt1.f=Rnd(100)-50
  4353.   mountycnt1.f=(Rnd(100)-50)
  4354.   mountxcnt2.f=Rnd(100)-50
  4355.   mountycnt2.f=(Rnd(100)-100)
  4356.   mountxcnt3.f=Rnd(100)-50
  4357.   mountycnt3.f=(Rnd(100)-100)
  4358.   points=0
  4359.   tmpwd=200
  4360.   tmpwdd=0
  4361.   tmpwddd=0
  4362.   tmpaz0=.5
  4363.   tmpazz=0
  4364.   tmpazzz=0
  4365.   tmpzz=0
  4366.   tmpz=0
  4367.   lines=0
  4368.   polygons=0
  4369.   tmpx=-100
  4370.   tmpy=-10100
  4371.   db_pvd=1
  4372.   db_pol=1
  4373.   db_lin=1
  4374.   db_col=2
  4375.   perc_interval=100/total_track_length
  4376.   perc_count=0
  4377.   perc_displ=1
  4378.   For n=1 To total_track_length
  4379.     perc_count+perc_interval
  4380.     If perc_count>=1
  4381.       Locate 10,3
  4382.       perc_displ+1
  4383.       perc_count-1
  4384.       NPrint perc_displ,"% Complete"
  4385.     EndIf
  4386.     CNIF 1=0
  4387.       If db_lin=1
  4388.         lines+1
  4389.         lin(lines)\l1=pnt(points+1)
  4390.         lin(lines)\l2=pnt(tmpprev)
  4391.         lin(lines)\col=db_col
  4392.         If db_col=2 Then db_col=hi_line_col Else db_col=2
  4393.       Else
  4394.         lines+1
  4395.         lin(lines)\l1=pnt(points+2)
  4396.         lin(lines)\l2=pnt(tmpprev+1)
  4397.         lin(lines)\col=db_col
  4398.       EndIf
  4399.       db_lin=1-db_lin
  4400.     CELSE
  4401.     If tmpprev>1
  4402.       If db_lin=1
  4403.         polygons+1
  4404.  
  4405.         ipol(polygons)\p1=(points+2)
  4406.         ipol(polygons)\p2=(points+3)
  4407.         ipol(polygons)\p3=(tmpprev)
  4408.         ipol(polygons)\p4=(tmpprev-1)
  4409.  
  4410.         pol(polygons)\p1=pnt(points+2);+2)
  4411.         pol(polygons)\p2=pnt(points+3);+3)
  4412.         pol(polygons)\p3=pnt(tmpprev)
  4413.         pol(polygons)\p4=pnt(tmpprev-1)
  4414.         pol(polygons)\col=db_col
  4415.         If db_col=2 Then db_col=hi_line_col Else db_col=2
  4416.       Else
  4417.         polygons+1
  4418.  
  4419.         ipol(polygons)\p1=(points+6)
  4420.         ipol(polygons)\p2=(points+1)
  4421.         ipol(polygons)\p3=(tmpprev-2)
  4422.         ipol(polygons)\p4=(tmpprev+3)
  4423.  
  4424.         pol(polygons)\p1=pnt(points+6);+4)
  4425.         pol(polygons)\p2=pnt(points+1);+1)
  4426.         pol(polygons)\p3=pnt(tmpprev-2)
  4427.         pol(polygons)\p4=pnt(tmpprev+3);+2)
  4428.         pol(polygons)\col=db_col
  4429.       EndIf
  4430.       db_lin=1-db_lin
  4431.     EndIf
  4432.     CEND
  4433.     If nofcolours>4
  4434.       db_pol+1
  4435.       If db_pol<5 OR db_pol>7 Then db_pol=5
  4436.     Else
  4437.       If db_pol=3 Then db_pol=1 Else db_pol=3
  4438.     EndIf
  4439.  
  4440.  
  4441.     CNIF 1=1
  4442.     polygons+1
  4443.  
  4444.     ipol(polygons)\p1=(points+3)
  4445.     ipol(polygons)\p2=(points+4)
  4446.     ipol(polygons)\p3=(tmpprev+1)
  4447.     ipol(polygons)\p4=(tmpprev)
  4448.  
  4449.     pol(polygons)\p1=pnt(points+3);+3)
  4450.     pol(polygons)\p2=pnt(points+4);+4)
  4451.     pol(polygons)\p3=pnt(tmpprev+1)
  4452.     pol(polygons)\p4=pnt(tmpprev)
  4453.  
  4454.     polygons+1
  4455.  
  4456.     ipol(polygons)\p1=(points+4)
  4457.     ipol(polygons)\p2=(points+5)
  4458.     ipol(polygons)\p3=(tmpprev+2)
  4459.     ipol(polygons)\p4=(tmpprev+1)
  4460.  
  4461.     pol(polygons)\p1=pnt(points+4);+3)
  4462.     pol(polygons)\p2=pnt(points+5);+4)
  4463.     pol(polygons)\p3=pnt(tmpprev+2);+1)
  4464.     pol(polygons)\p4=pnt(tmpprev+1);)
  4465.  
  4466.     polygons+1
  4467.  
  4468.     ipol(polygons)\p1=(points+5)
  4469.     ipol(polygons)\p2=(points+6)
  4470.     ipol(polygons)\p3=(tmpprev+3)
  4471.     ipol(polygons)\p4=(tmpprev+2)
  4472.  
  4473.     pol(polygons)\p1=pnt(points+5);+3)
  4474.     pol(polygons)\p2=pnt(points+6);+4)
  4475.     pol(polygons)\p3=pnt(tmpprev+3);+1)
  4476.     pol(polygons)\p4=pnt(tmpprev+2);)
  4477.  
  4478.     If nofcolours>4
  4479.  
  4480.       db_lpol=QAbs(land1{tmpx-20,tmpy}-land1{tmpx+20,tmpy})
  4481.       db_lpol+QAbs(land1{tmpx,tmpy-20}-land1{tmpx,tmpy+20})
  4482.  
  4483.       tmpx2=tmpx+tmpwd*Cos(tmpaz)/3
  4484.       tmpy2=tmpy-tmpwd*Sin(tmpaz)/3
  4485.       db_lpol2=QAbs(land1{tmpx2,tmpy2}-land1{tmpx2+20,tmpy2})
  4486.       db_lpol2+QAbs(land1{tmpx2,tmpy2-20}-land1{tmpx2,tmpy2+20})
  4487.  
  4488.       tmpx2=tmpx+tmpwd*Cos(tmpaz)*2/3
  4489.       tmpy2=tmpy-tmpwd*Sin(tmpaz)*2/3
  4490.       db_lpol3=QAbs(land1{tmpx2,tmpy2}-land1{tmpx2+20,tmpy2})
  4491.       db_lpol3+QAbs(land1{tmpx2,tmpy2-20}-land1{tmpx2,tmpy2+20})
  4492.  
  4493.       max_dblpol=Max(db_lpol,max_dblpol)
  4494.       EndIf
  4495.  
  4496.     If nofcolours>4
  4497.       db_lpol_c2=2-db_lpol_c2
  4498.       pol(polygons-2)\col=QLimit(Rnd(3)+32-db_lpol,16,32)
  4499.       pol(polygons-1)\col=QLimit(Rnd(3)+32-db_lpol2,16,32)
  4500. ;QLimit(31+db_lpol_c2-db_lpol,16,32)
  4501.       pol(polygons)\col=QLimit(Rnd(3)+32-db_lpol3,16,32)
  4502.     Else
  4503.       pol(polygons-1)\col=db_pol
  4504.       If db_pol=3 Then db_pol_c2=1 Else db_pol_c2=3
  4505.       pol(polygons)\col=db_pol_c2
  4506.       pol(polygons-2)\col=db_pol_c2
  4507.     EndIf
  4508.  
  4509.     CEND
  4510.  
  4511.     tmpaz=tmpaz0+oval_track*n*2*Pi/150
  4512.     points+1
  4513.  
  4514.  
  4515. ; Check Wether Road is Out of Map Bounds
  4516. ;=======================================
  4517.  
  4518. road_out_of_bounds:
  4519.     tmpprev=points+2
  4520.  
  4521.     If RectsHit(tmpx/10+40*Sin(tmpaz),tmpy/10+40*Cos(tmpaz),1,1,-2000,-2000,4000,4000)
  4522.       tmpz=land1{tmpx,tmpy}
  4523.       tmpzd=(tmpz-land1{tmpx+100,tmpy+100})/100
  4524.       tmpzd=1+QAbs(tmpzd)
  4525.       tmpx+64*Sin(tmpaz)/tmpzd
  4526.       tmpy+64*Cos(tmpaz)/tmpzd
  4527.     Else
  4528.       tmpaz=QWrap(tmpaz+Pi/8,0,p2)
  4529.     EndIf
  4530.  
  4531.     db_pv+1:If db_pv>3 Then db_pv=1
  4532.  
  4533.  
  4534. CNIF 1=0
  4535.     If db_pv=3
  4536.  
  4537.       last_polygon_p=this_polygon_p
  4538.       this_polygon_p=points
  4539.  
  4540.       polygons+1
  4541.  
  4542.       ipol(polygons)\p1=(this_polygon_p)
  4543.       ipol(polygons)\p2=(this_polygon_p+5)
  4544.       ipol(polygons)\p3=(last_polygon_p+5)
  4545.       ipol(polygons)\p4=(last_polygon_p)
  4546.  
  4547.       pol(polygons)\p1=(this_polygon_p+2)
  4548.       pol(polygons)\p2=(this_polygon_p+5)
  4549.       pol(polygons)\p3=(last_polygon_p+5)
  4550.       pol(polygons)\p4=(last_polygon_p+2)
  4551.       pol(polygons)\col=2
  4552.  
  4553.     EndIf
  4554. CEND
  4555.  
  4556.  
  4557. ;   ###################
  4558. ;   #                 #
  4559. ;   # Add Road Points #
  4560. ;   #                 #
  4561. ;   ###################
  4562.  
  4563.  
  4564. ; The Intermediate Points
  4565. ; =======================
  4566.  
  4567. CNIF 1=1
  4568.  
  4569.     px(points)=tmpx+(tmpwd+6)*Cos(tmpaz)
  4570.     py(points)=tmpy-(tmpwd+6)*Sin(tmpaz)
  4571.     tmpz=land1{px(points),py(points)}
  4572.     pz(points)=tmpz*mountain
  4573.     point_value(points)=0
  4574.  
  4575.     points+1
  4576.     px(points)=tmpx-6*Cos(tmpaz)
  4577.     py(points)=tmpy+6*Sin(tmpaz)
  4578.     tmpz=land1{px(points),py(points)}
  4579.     pz(points)=tmpz*mountain
  4580.     point_value(points)=0
  4581. CEND
  4582.  
  4583. ; The Points on the left
  4584. ; ======================
  4585.  
  4586.     points+1
  4587.     px(points)=tmpx
  4588.     py(points)=tmpy
  4589.     tmpz=land1{px(points),py(points)}
  4590.     tmpleft=tmpz
  4591.     pz(points)=tmpz*mountain
  4592.     point_value(points)=2;db_pv
  4593.  
  4594.  
  4595. ; The Points on the middle
  4596. ;========================
  4597.     points+1
  4598.     px(points)=tmpx+tmpwd*Cos(tmpaz)/3
  4599.     py(points)=tmpy-tmpwd*Sin(tmpaz)/3
  4600.     tmpz=land1{px(points),py(points)}
  4601.     pz(points)=tmpz*mountain
  4602.    point_value(points)=db_pv
  4603.  
  4604.     points+1
  4605.     px(points)=tmpx+tmpwd*Cos(tmpaz)*2/3
  4606.     py(points)=tmpy-tmpwd*Sin(tmpaz)*2/3
  4607.     tmpz=land1{px(points),py(points)}
  4608.     pz(points)=tmpz*mountain
  4609.    point_value(points)=db_pv
  4610.  
  4611. ; The Points on the right
  4612. ;========================
  4613.     points+1
  4614.     px(points)=tmpx+tmpwd*Cos(tmpaz)
  4615.     py(points)=tmpy-tmpwd*Sin(tmpaz)
  4616.     tmpz=land1{px(points),py(points)}
  4617.     tmpright=tmpz
  4618.     pz(points)=tmpz*mountain
  4619.    point_value(points)=2;db_pv
  4620.  
  4621.  
  4622.  
  4623. ; Set Up Slippery Places In Map
  4624. ; =============================
  4625.  
  4626.     r_xstart=Min(tmpx/32+640,px(points)/32+640)
  4627.     r_ystart=Min(tmpy/32+640,py(points)/32+640)
  4628.     r_xend=Max(tmpx/32+640,px(points)/32+640)
  4629.     r_yend=Max(tmpy/32+640,py(points)/32+640)
  4630.     For r_x=QLimit(r_xstart-8,0,1024) To QLimit(r_xend+5,0,1024)
  4631.       For r_y=QLimit(r_ystart-8,0,1024) To QLimit(r_yend+5,0,1024)
  4632.         slippery(r_x,r_y)=0;QLimit(-tmpz,0,127)
  4633.       Next r_y
  4634.     Next r_x
  4635.  
  4636.  
  4637.  
  4638.  
  4639.     mtmpline=6
  4640.     max_value=3
  4641.  
  4642.  
  4643. ; Create turns and stuff
  4644. ; ======================
  4645.  
  4646.     tmpwd=QLimit(tmpwd+tmpwdd,150,300)
  4647.     tmpwdd=QLimit(tmpwdd+tmpwddd,-20,20)
  4648.     tmpwddd=QLimit(tmpwddd+Rnd-.5,-5,5)
  4649. ;    tmpazz+(tmpleft-tmpright)/100
  4650. ;    If tmpleft<tmpright Then tmpazz+.1 Else tmpazz-.1
  4651.  
  4652.     tmpinc1=QLimit(tmpinc1+tmpinc2,.5,1.5)
  4653.     tmpinc2=QLimit(tmpinc2+.01*(Rnd-.5),-.125,.125)
  4654.     tmpz=(tmpleft+tmpright)*.5
  4655.     dtmpz=tmpz-otmpz
  4656.     otmpz=tmpz
  4657.     tmpinc3=5/(5+QLimit(dtmpz,-4,20))
  4658.  
  4659.     tmpazz=tmpinc3*tmpinc1*inclined_turns*(tmpright-tmpleft)/128
  4660. ;    tmpazz=(1+QAbs(tmpazz2))*inclined_turns*(tmpright-tmpleft)/128
  4661.     tmpazd0=tmpaz0+tmpazz+tmpazz2
  4662.  
  4663.     If tmpazd0<-4
  4664.       tmpazz2+Rnd
  4665.       tmpazzz+Rnd
  4666.       tmpazd1+.01
  4667.     Else
  4668.       If tmpazd0>4
  4669. ;        tmpazd0+Rnd
  4670.         tmpazz2-Rnd
  4671.         tmpazzz-Rnd
  4672.         tmpazd1-.01
  4673.       Else
  4674.         tmpazd1=tmpazd1*.9
  4675.       EndIf
  4676.     EndIf
  4677.  
  4678.     tmpaz0=QLimit(tmpazd0+tmpazd1,-4,4)
  4679. ;    tmpaz0=QLimit(tmpaz0+tmpazz,-4,4)
  4680.  
  4681.  
  4682.     tmpazz2=QLimit(tmpazz2+.01*tmpazzz,-max_turns,max_turns)
  4683.     tmpcount-1
  4684.     If tmpcount<0
  4685.       If tmpazz2>0
  4686.         tmpazzd=1
  4687.  
  4688.       Else
  4689.         tmpazzd=-1
  4690.       EndIf
  4691.       If Rnd<.1
  4692.         tmpazz3=tmpazzd*Rnd*4
  4693.       Else
  4694.         tmpazz3=-tmpazzd*Rnd*4
  4695.       EndIf
  4696.       tmpcount=Rnd(10)+2
  4697.     EndIf
  4698.     tmpazzz=tmpazz3;(tmpazzz*7+tmpazz3)/8
  4699.     ;tmpazzz=QWrap(tmpazzz+Rnd/4-.125,-1,1)
  4700.  
  4701.     tmpzzz=QWrap(tmpzzz+(Rnd-.5),-1,1)
  4702.     tmpzz=QLimit(tmpzz+tmpzzz,-10,10)
  4703.     tmpz2=QLimit(tmpz2+tmpzz,-128,127)
  4704.     tmpline+1
  4705.  
  4706.  
  4707.   Next n
  4708.  
  4709.  
  4710. ;.landscape
  4711. ;  For m=0 To 1023
  4712. ;    For n=0 To 1023
  4713. ;      heightmap(m,n)=-32767
  4714. ;    Next n
  4715. ;  Next m
  4716.  
  4717.  
  4718.   Return
  4719.  
  4720.  
  4721. .reset_car
  4722.     map_slip=0
  4723.     vx=0:vy=-10000:vz=land1{vx,vy}*mountain-11
  4724.     gear=0
  4725.     vux=0:vuy=0:vuz=0
  4726.     vax=0:vaz=.5:vay=0
  4727.     ovux=0:ovuy=0:ovuz=0
  4728.     rux=0:orux=0
  4729.     ruy=0:oruy=0
  4730.     cvaz=Cos(vaz)
  4731.     svaz=Sin(vaz)
  4732.     cvay=Cos(vay)
  4733.     svay=Sin(vay)
  4734.     cvax=Cos(vax)
  4735.     svax=Sin(vax)
  4736.     susp1=0:susp2=0:susp3=0:susp4=0
  4737.     osusp1=0:osusp2=0:osusp3=0:osusp4=0
  4738.     osusp5=0
  4739.     dxsusp5=0
  4740.     odxsusp=0
  4741.     dxsusp=0
  4742.     susp5=0
  4743.  
  4744.     wz=0
  4745.     vwz=0
  4746.     forceonx2=0:downforce=0
  4747.     Force_on_X=0
  4748.     Force_on_Z=0
  4749.     upside_down=False
  4750.     vec_obj(0)\x=100
  4751.     vec_obj(0)\y=-10000
  4752.     vec_obj(0)\z=0
  4753.     vec_obj(0)\ax=0
  4754.     vec_obj(0)\ay=0
  4755.     vec_obj(0)\az=0
  4756.     LoopSound 4,8
  4757.  
  4758.     point_start=0:point_end=points1-1
  4759.     point_min=1
  4760.     point_max=points1
  4761.     start_point=1
  4762.     end_point=points1
  4763.     closest_point=1
  4764.     rep_point=0
  4765.  
  4766.   Return
  4767.  
  4768. .race_phantom
  4769.  
  4770.  
  4771.     Gosub reset_car
  4772.     racing=True
  4773.  
  4774.     CNIF #SYSTEM_FRIENDLY=0
  4775.     Use BitMap 0
  4776.     Cls
  4777.     Show 0
  4778.     BitMapOutput 0
  4779.     Locate 10,10
  4780.     NPrint "Get Ready"
  4781.  
  4782.     VWait 50
  4783.     CEND
  4784.  
  4785.  
  4786.  
  4787.   Return
  4788.  
  4789. .back_to_gui
  4790. CNIF #SYSTEM_FRIENDLY=0
  4791.   Mouse Off
  4792.   ClrInt 5
  4793.   Free BitMap 0
  4794.   Free BitMap 1
  4795.   FreeSlices
  4796. ;  Free Screen 1
  4797.   AMIGA
  4798. CEND
  4799. ShowScreen 0
  4800. Use Window 0
  4801. Activate 0
  4802. WLocate 1,1
  4803. Print "FPS%:"
  4804. NPrint 100*nofcounts/nofframes,"  "
  4805. Volume 1|2|4|8,0,0,0,0
  4806. Goto myGUI
  4807.  
  4808. .finish
  4809.  
  4810. CNIF #SYSTEM_FRIENDLY=0
  4811.   ClrInt 5
  4812.   Free BitMap 0
  4813.   Free BitMap 1
  4814.   FreeSlices
  4815.   AMIGA
  4816.  
  4817.   Free Screen 1
  4818. CEND
  4819.  
  4820. Use Window 0
  4821. Print "FPS:"
  4822. NPrint 50*nofcounts/nofframes
  4823. VWait 50
  4824. finish2:
  4825. CloseWindow 0
  4826. finish3:
  4827. End
  4828.  
  4829. _nofast:
  4830. tempb.b=RTEZRequest("Memory Alert","Not enough Fast RAM!","OK")
  4831. Goto finish3
  4832.  
  4833. _nochip:
  4834. tempb.b=RTEZRequest("Memory Alert","Not enough Chip RAM","OK")
  4835. Goto finish3
  4836.  
  4837. .view_car
  4838.   Gosub select_car
  4839.   Window 1,0,0,320,100,2|4|8,"Car Stats",2,1
  4840.   WLocate 1,1
  4841.   NPrint "HP:",HPower*100
  4842.   Print "Drive:"
  4843.   If rw_drive=True Then NPrint "Rear"
  4844.   If fw_drive=True Then NPrint "Front"
  4845.   If FR_drive=True
  4846.     NPrint "4x4:",power_ratio*100,"%"
  4847.   EndIf
  4848.   NPrint "Drag:",wing_strength*drag_factor
  4849.   NPrint "Wing Effectiveness:",wing_strength
  4850.   NPrint "Wing Ratio - F:",front_wing*100,"% R:",rear_wing*100,"%"
  4851.   NPrint "Weight Ratio:",motor_position*50,"%"
  4852.   NPrint "Tyre type:",tyre_pressure
  4853.   NPrint "Suspension Strength:",susp_strength
  4854.  
  4855.   Repeat
  4856.     ev.l=WaitEvent
  4857.  
  4858.   Until ev=$200
  4859.   Free Window 1
  4860.   Use Window 0
  4861.   Return
  4862.  
  4863. .select_car
  4864. rw_drive=False
  4865. fw_drive=False
  4866. FR_drive=False
  4867.  
  4868. engined$="engine2"
  4869. has_turbo=False
  4870. rev_limit=1;.99
  4871. susp_strength=1
  4872. rev_limiter=1
  4873. field_advantage=1
  4874. rear_wing=.5
  4875. front_wing=.5
  4876. turbo_max=1.25
  4877. turbo_boost=200
  4878. turbo_dsp=130
  4879. troll_off=1/16
  4880. Select car_choice
  4881.   Case 0
  4882.     WLocate 1,1
  4883.     NPrint "BLEURGH_ERROR!"
  4884.   Case 1
  4885.     troll_off=1/64
  4886.     rev_max=6000
  4887.     turbo_boost=500
  4888.     tyre_pressure=1
  4889.     wing_strength=.06
  4890.     drag_factor=1.5
  4891.     HPower=1.8
  4892.     fw_drive=True
  4893.     power_ratio=1
  4894.     motor_position=1
  4895.     gear_ratio1(1)=64/10
  4896.     gear_ratio1(2)=64/18
  4897.     gear_ratio1(3)=64/26
  4898.     gear_ratio1(4)=64/34
  4899.     gear_ratio1(5)=64/42
  4900.     gear_ratio1(6)=64/50
  4901.     has_turbo=True
  4902.     ruyscale=1
  4903.     car_turn_factor=.45
  4904.     susp_strength=.6
  4905.     rear_wing=.6
  4906.     front_wing=.4
  4907.     field_advantage=2
  4908.     engined$="engine3b"
  4909.     turbod$="engine3"
  4910.  
  4911.   Case 2
  4912.     troll_off=1/64
  4913.     rev_max=6000
  4914.     turbo_boost=450
  4915.     tyre_pressure=1.5
  4916.     wing_strength=.07
  4917.     drag_factor=1.5
  4918.     HPower=1.9
  4919.     rw_drive=True
  4920.     power_ratio=0
  4921.     motor_position=1
  4922.     gear_ratio1(1)=64/10
  4923.     gear_ratio1(2)=64/20
  4924.     gear_ratio1(3)=64/30
  4925.     gear_ratio1(4)=64/40
  4926.     gear_ratio1(5)=64/50
  4927.     gear_ratio1(6)=64/60
  4928.     has_turbo=True
  4929.     ruyscale=1.1
  4930.     car_turn_factor=.5
  4931.     susp_strength=.6
  4932.     rear_wing=.7
  4933.     front_wing=.3
  4934.     field_advantage=2
  4935.     engined$="engine2a"
  4936.     turbod$="engine2"
  4937.  
  4938.  
  4939.   Case 3
  4940.     troll_off=1/48
  4941.     rev_max=6500
  4942.     turbo_max=1.5
  4943.     turbo_boost=400
  4944.     tyre_pressure=2.5
  4945.     wing_strength=.09
  4946.     drag_factor=1.3
  4947.     HPower=2.1
  4948.     FR_drive=True
  4949.     power_ratio=.4
  4950.     motor_position=1
  4951.     gear_ratio1(1)=64/20
  4952.     gear_ratio1(2)=64/27
  4953.     gear_ratio1(3)=64/34
  4954.     gear_ratio1(4)=64/41
  4955.     gear_ratio1(5)=64/45
  4956.     gear_ratio1(6)=64/48
  4957.     has_turbo=True
  4958.     ruyscale=.8
  4959.     car_turn_factor=.65
  4960.     susp_strength=.7
  4961.     rear_wing=.7
  4962.     front_wing=.3
  4963.     field_advantage=3
  4964.     engined$="engine5t"
  4965.     turbod$="engine5t2"
  4966.  
  4967.  
  4968.  
  4969.   Case 4
  4970.     troll_off=1/32
  4971.     rev_max=7000
  4972.     turbo_boost=160
  4973.     tyre_pressure=2
  4974.     wing_strength=.08
  4975.     drag_factor=1.3
  4976.     HPower=2.3
  4977.     FR_drive=True
  4978.     power_ratio=.2
  4979.     motor_position=1
  4980.     gear_ratio1(1)=64/20
  4981.     gear_ratio1(2)=64/28
  4982.     gear_ratio1(3)=64/36
  4983.     gear_ratio1(4)=64/44
  4984.     gear_ratio1(5)=64/58
  4985.     gear_ratio1(6)=64/52
  4986.     has_turbo=True
  4987.     ruyscale=.78
  4988.     car_turn_factor=.6
  4989.     susp_strength=.7
  4990.     rear_wing=.2
  4991.     front_wing=.8
  4992.     field_advantage=3
  4993.     engined$="engine1b"
  4994.     turbod$="engine1"
  4995.  
  4996.  
  4997.   Case 5
  4998.     troll_off=1/32
  4999.     rev_max=8000
  5000.     turbo_max=1.5
  5001.     turbo_boost=300
  5002.     tyre_pressure=3
  5003.     wing_strength=.11
  5004.     drag_factor=.92
  5005.     HPower=4
  5006.     rw_drive=True
  5007.     power_ratio=0
  5008.     motor_position=2
  5009.     gear_ratio1(1)=64/32
  5010.     gear_ratio1(2)=64/42
  5011.     gear_ratio1(3)=64/52
  5012.     gear_ratio1(4)=64/62
  5013.     gear_ratio1(5)=64/72
  5014.     gear_ratio1(6)=64/80
  5015.     has_turbo=True
  5016.     ruyscale=.7
  5017.     car_turn_factor=.675
  5018.     susp_strength=.8
  5019.     rear_wing=.9
  5020.     front_wing=.1
  5021.     field_advantage=1.5
  5022.     engined$="engine3"
  5023.     turbod$="engine3t"
  5024.  
  5025.  
  5026.   Case 6
  5027.     troll_off=1/32
  5028.     rev_max=7500
  5029.     turbo_boost=250
  5030.     drag_factor=.95
  5031.     tyre_pressure=4
  5032.     wing_strength=.12
  5033.     HPower=3.5
  5034.     FR_drive=True
  5035.     power_ratio=.25
  5036.     motor_position=3
  5037.     gear_ratio1(1)=64/28
  5038.     gear_ratio1(2)=64/38
  5039.     gear_ratio1(3)=64/48
  5040.     gear_ratio1(4)=64/58
  5041.     gear_ratio1(5)=64/68
  5042.     gear_ratio1(6)=64/78
  5043.     has_turbo=True
  5044.     ruyscale=.7
  5045.     car_turn_factor=.7
  5046.     susp_strength=.8
  5047.     rear_wing=.6
  5048.     front_wing=.4
  5049.     field_advantage=1.6
  5050.     engined$="engine2"
  5051.     turbod$="engine2t"
  5052.  
  5053.  
  5054.  
  5055.  
  5056.   Case 7
  5057.     troll_off=1/16
  5058.     rev_max=9000
  5059.     turbo_boost=200
  5060.     tyre_pressure=4
  5061.     wing_strength=.11
  5062.     drag_factor=.9
  5063.     HPower=6
  5064.     rw_drive=True
  5065.     power_ratio=0
  5066.     motor_position=2
  5067.     gear_ratio1(1)=64/32
  5068.     gear_ratio1(2)=64/44
  5069.     gear_ratio1(3)=64/56
  5070.     gear_ratio1(4)=64/68
  5071.     gear_ratio1(5)=64/80
  5072.     gear_ratio1(6)=64/88
  5073.     has_turbo=True
  5074.     ruyscale=.65
  5075.     car_turn_factor=.8
  5076.     rear_wing=.6:front_wing=.4
  5077.     field_advantage=1.2
  5078.     engined$="engine6a"
  5079.     turbod$="engine6b"
  5080.  
  5081.   Case 8
  5082.     troll_off=1/8
  5083.     rev_max=12000
  5084.     turbo_max=1.1
  5085.     turbo_boost=170
  5086.     tyre_pressure=4
  5087.     wing_strength=.18
  5088.     drag_factor=1.1
  5089.     HPower=8
  5090.     rw_drive=True
  5091.     power_ratio=0
  5092.     motor_position=2
  5093.     gear_ratio1(1)=64/30;2;1.5
  5094.     gear_ratio1(2)=64/40;1.6589;1.2
  5095.     gear_ratio1(3)=64/50;.5;1.3824;1
  5096.     gear_ratio1(4)=64/60;1.152;.85
  5097.     gear_ratio1(5)=64/70;.5;.96;.8
  5098.     gear_ratio1(6)=64/80;.8192;.8;.79
  5099.     has_turbo=True
  5100.     ruyscale=.65
  5101.     car_turn_factor=.9
  5102.     rear_wing=.5:front_wing=.5
  5103.     field_advantage=1
  5104.     engined$="engine1a"
  5105.     turbod$="engine1t2"
  5106.  
  5107.   Case 9
  5108.     troll_off=1/2
  5109.     rev_max=11000
  5110.     turbo_dsp=250
  5111.     turbo_boost=400
  5112.     tyre_pressure=4
  5113.     wing_strength=.02
  5114.     drag_factor=2
  5115.     HPower=6
  5116.     rev_limit=.9
  5117.     FR_drive=True
  5118.     power_ratio=.5
  5119.     motor_position=2
  5120.     gear_ratio1(1)=64/10
  5121.     gear_ratio1(2)=64/30
  5122.     gear_ratio1(3)=64/50
  5123.     gear_ratio1(4)=64/70
  5124.     gear_ratio1(5)=64/80
  5125.     gear_ratio1(6)=64/90
  5126.     has_turbo=False
  5127.     ruyscale=.65
  5128.     car_turn_factor=.6
  5129.     susp_strength=.5
  5130.     rev_limiter=.5
  5131.     field_advantage=3
  5132.     engined$="engine4b"
  5133.     turbod$="engine4t"
  5134.   Default
  5135.     no_choice_made=True
  5136. End Select
  5137. wing_strength=wing_strength*wing_strength_adj
  5138. ;wing_strength*4
  5139. HPower*f_multiplier
  5140. drag_factor*f_multiplier
  5141. tyre_pressure*2
  5142. car_turn_factor*.5
  5143. gear_ratio1(0)=1000
  5144. If no_choice_made=True Then Goto select_cars
  5145. weight_ratio=2+(motor_position-2)/2
  5146.  
  5147.  
  5148.  
  5149. weight_front=3/(1+weight_ratio)
  5150. weight_rear=weight_front*weight_ratio
  5151.  
  5152.  
  5153. Return
  5154. .crap
  5155.  
  5156.  
  5157. Return
  5158.  
  5159. clear_landscape:
  5160.   For m=0 To 255
  5161.       GetReg a0,&heightmap(0,m)
  5162.       MOVE.w #255,d0
  5163.   _asm_clear_land:
  5164.       MOVE.w #0,(a0)+
  5165.       SUBQ.w #1,d0
  5166.       BGE _asm_clear_land
  5167.   Next m
  5168.  
  5169.  
  5170.   Return
  5171.  
  5172.  
  5173.  
  5174.  
  5175. _filtfreq: Dc.l 0
  5176.  
  5177.  
  5178.